私は Contact Framework で作業していました (連絡先を追加するだけです)。そして、問題なく保存されました(連絡先リストを再確認しました)が、最近、コンソールに次のメッセージが表示されることに気付きました。
2015-06-12 09:57:39.723 AddingContactToAddressBook[819:291346] HangTracer 間隔は 0、強制的に 1 秒
2015-06-12 09:57:39.725 AddingContactToAddressBook[819:291346] 新しい hangtracer connection:0x332e10 を作成
私はそれをグーグルで検索しましたが、Twitter で「これはどのような新しい魔法ですか?」という言及しか見つかりませんでした。
実際、私のコードがこの問題の原因であるかどうかはわかりません。
-(void)verifyUserAuthorizationInIOS9andLower{
CNContactStore * contactStore = [[CNContactStore alloc]init];
if ([CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts] == CNAuthorizationStatusNotDetermined) {
[contactStore requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * __nullable error) {
if (granted==YES) {
[self addContactInIOS9andLower];
if ([self addContactInIOS9andLower]) {
NSLog(@"Error");
}
else{
NSLog(@"Error");
}
}
else{
NSLog(@"Error");
}
}];
}
else if ([CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts] == CNAuthorizationStatusAuthorized){
[self addContactInIOS9andLower];
}
else {
NSLog(@"Error");
}
}
-(BOOL)addContactInIOS9andLower{
CNContactStore * contactStore = [[CNContactStore alloc]init];
CNMutableContact *mutableContact = [[CNMutableContact alloc]init];
mutableContact.givenName = name;
mutableContact.familyName = lastname;
mutableContact.phoneNumbers = [[NSArray alloc]initWithObjects:[CNLabeledValue labeledValueWithLabel:CNLabelPhoneNumberiPhone value:[CNPhoneNumber phoneNumberWithStringValue:phone]], nil];
CNSaveRequest * saveRequest = [[CNSaveRequest alloc]init];
[saveRequest addContact:mutableContact toContainerWithIdentifier:nil];
NSError *error = nil;
if ([contactStore executeSaveRequest:saveRequest error:&error]){
return NO;
}
else{
return YES;
}
}