AdressBook崩溃,只有一些接触! [英] AdressBook Crash, only with some contacts!

查看:376
本文介绍了AdressBook崩溃,只有一些接触!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序崩溃,这是从通讯簿API产生的问题,它只是用一些接触情况。

下面是日志:

 异常类型:EXC_BREAKPOINT(SIGTRAP)
异常codeS:0x00000102,0x316ebd38
坠毁主题:0螺纹0坠毁:
0的CoreFoundation 0x00001cfe CFRetain + 90
1通讯簿0x00004b2c ABCMultiValueCopyValueAtIndex + 28
2通讯簿0x0001066a ABMultiValueCopyValueAtIndex + 2
3呼叫监听0x00003824 - [CallAppDelegate peoplePickerNavigationController:shouldContinueAfterSelectingPerson:属性:标识符:(AppDelegate.m:408)
4 AddressBookUI 0x00032cfc - [的ABPeoplePickerNavigationController personViewController:shouldPerformDefaultActionForPerson:属性:标识符:withMemberCell:] + 152
5 AddressBookUI 0x0003b8ce - [ABPersonViewControllerHelper personTableViewDataSource:selectedPropertyAtIndex:inPropertyGroup:withMemberCell:forEditing:] + 222
6 AddressBookUI 0x0004a17c - [ABPersonTableViewDataSource valueAtIndex:selectedForPropertyGroup:withMemberCell:forEditing:] + 40
7 AddressBookUI 0x00048c00 - [ABPersonTableViewDataSource的tableView:didSelectRowAtIndexPath方法:] + 316
8 UIKit的0x00091f40 - [UITableView的_selectRowAtIndexPath:动画:的scrollPosition:notifyDelegate:] + 656
9 UIKit的0x0009db40 - [UITableView的_userSelectRowAtIndexPath:] + 124
10基金0x00086c86 __NSFireDelayedPerform + 362
11的CoreFoundation 0x00071a54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
12的CoreFoundation 0x00073ede __CFRunLoopDoTimer + 854
13的CoreFoundation 0x0007485e __CFRunLoopRun + 1082
14的CoreFoundation 0x0001d8e4 CFRunLoopRunSpecific + 224
15的CoreFoundation 0x0001d7ec CFRunLoopRunInMode + 52
16 GraphicsServices 0x000036e8 GSEventRunModal + 108
17 GraphicsServices 0x00003794 GSEventRun + 56
18 UIKit的0x000062a0 - [UIApplication的_run] + 396
19 UIKit的0x00004e10 UIApplicationMain + 664
20呼叫监听0x000028e8主(main.m文件:14)
21呼叫监听0x000028b8启动+ 32

这是推动我疯了,因为它仅与联系人的数量孤立发生。

任何帮助将大大AP preciated。

下面是被请求的code,非常感谢你非常多的帮助:

(这是从哪儿我认为错误发生的方法的提取物)

奇怪的是,它只能使用特定的接触情况,和删除联系人,然后创建一个新的解决问题...

   - (BOOL)peoplePickerNavigationController:(*的ABPeoplePickerNavigationController)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)人
                                属性:(ABPropertyID)属性标识符:(ABMultiValueIdentifier)标识符    * NSString的的firstName =(的NSString *)ABRecordCopyValue(人,kABPersonFirstNameProperty);
    * NSString的= lastName的(* NSString的)ABRecordCopyValue(人,kABPersonLastNameProperty);
    *的NSNumber纪录= [NSNumber的numberWithInt:ABRecordGetRecordID(人)];
    如果(lastName的!=无){
        名称= [的NSString stringWithFormat:@%@%@,名字,姓氏]
    }
    其他{
        名称=名字;
    }        ABMultiValueRef手机= ABRecordCopyValue(人身,财产);
        * NSString的值=(的NSString *)ABMultiValueCopyValueAtIndex(电话,标识符);
        * NSString的标签=(的NSString *)ABMultiValueCopyLabelAtIndex(电话,标识符);
        NSMutableArray里* tempArray = [[NSMutableArray里的alloc] initWithArray:[[NSUserDefaults的standardUserDefaults] objectForKey:@MainArray]];
        *的NSDictionary = stringDictionary [NSDictionary的dictionaryWithObjectsAndKeys:姓名,kLabelKey,价值,kNumberKey,标签,kNumberLabelKey,记录,kReferenceKey,零]
        [tempArray ADDOBJECT:stringDictionary];
        NSArray的* mainArray = [NSArray的arrayWithArray:tempArray];
        [NSUserDefaults的standardUserDefaults]的setObject:mainArray forKey:@MainArray];


解决方案

要有人遇到了类似的问题:

从事实来我的错误,我用:

ABMultiValueCopyValueAtIndex 的标识符,而不是指数。

您必须调用 ABMultiValueGetIndexForIdentifier ,然后使用该指数对 ABMultiValueCopyValueAtIndex

底线是标识符!=指数

My app crashes, it is a problem that arises from the AddressBook API, it only happens with some contacts.

Here is the log:

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x00000102, 0x316ebd38
Crashed Thread:  0

Thread 0 Crashed:
0   CoreFoundation                    0x00001cfe CFRetain + 90
1   AddressBook                       0x00004b2c ABCMultiValueCopyValueAtIndex + 28
2   AddressBook                       0x0001066a ABMultiValueCopyValueAtIndex + 2
3   Call Monitor                      0x00003824 -[CallAppDelegate peoplePickerNavigationController:shouldContinueAfterSelectingPerson:property:identifier:] (AppDelegate.m:408)
4   AddressBookUI                     0x00032cfc -[ABPeoplePickerNavigationController personViewController:shouldPerformDefaultActionForPerson:property:identifier:withMemberCell:] + 152
5   AddressBookUI                     0x0003b8ce -[ABPersonViewControllerHelper personTableViewDataSource:selectedPropertyAtIndex:inPropertyGroup:withMemberCell:forEditing:] + 222
6   AddressBookUI                     0x0004a17c -[ABPersonTableViewDataSource valueAtIndex:selectedForPropertyGroup:withMemberCell:forEditing:] + 40
7   AddressBookUI                     0x00048c00 -[ABPersonTableViewDataSource tableView:didSelectRowAtIndexPath:] + 316
8   UIKit                             0x00091f40 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 656
9   UIKit                             0x0009db40 -[UITableView _userSelectRowAtIndexPath:] + 124
10  Foundation                        0x00086c86 __NSFireDelayedPerform + 362
11  CoreFoundation                    0x00071a54 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
12  CoreFoundation                    0x00073ede __CFRunLoopDoTimer + 854
13  CoreFoundation                    0x0007485e __CFRunLoopRun + 1082
14  CoreFoundation                    0x0001d8e4 CFRunLoopRunSpecific + 224
15  CoreFoundation                    0x0001d7ec CFRunLoopRunInMode + 52
16  GraphicsServices                  0x000036e8 GSEventRunModal + 108
17  GraphicsServices                  0x00003794 GSEventRun + 56
18  UIKit                             0x000062a0 -[UIApplication _run] + 396
19  UIKit                             0x00004e10 UIApplicationMain + 664
20  Call Monitor                      0x000028e8 main (main.m:14)
21  Call Monitor                      0x000028b8 start + 32

This is driving me crazy, as it only happens with an isolated number of contacts.

Any help would be greatly appreciated.

Here is the code that was requested, thank you very very much for your help:

(It is an extract from the method where I think the error happens)

The weird thing is that it only happens with certain contacts, and deleting the contact, then creating a new one solves the problem...

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person 
                                property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier

    NSString* firstName = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
    NSString* lastName = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
    NSNumber* record = [NSNumber numberWithInt:ABRecordGetRecordID(person)];
    if(lastName!=nil){
        name=[NSString stringWithFormat:@"%@ %@",firstName,lastName];
    }
    else {
        name=firstName;
    }

        ABMultiValueRef phone = ABRecordCopyValue(person, property);
        NSString *value =(NSString *)ABMultiValueCopyValueAtIndex(phone, identifier);
        NSString *label =(NSString *)ABMultiValueCopyLabelAtIndex(phone, identifier);
        NSMutableArray *tempArray=[[NSMutableArray alloc] initWithArray:[[NSUserDefaults  standardUserDefaults] objectForKey:@"MainArray"]];
        NSDictionary *stringDictionary = [NSDictionary dictionaryWithObjectsAndKeys:name, kLabelKey, value, kNumberKey,label, kNumberLabelKey,record, kReferenceKey, nil];
        [tempArray addObject:stringDictionary];
        NSArray *mainArray = [NSArray arrayWithArray:tempArray];
        [[NSUserDefaults standardUserDefaults] setObject:mainArray forKey:@"MainArray"];

解决方案

To anyone experiencing a similar problem:

My error came from the fact that I was using:

ABMultiValueCopyValueAtIndex with an identifier instead of an index.

You have to call ABMultiValueGetIndexForIdentifier and then use that index on the ABMultiValueCopyValueAtIndex.

The bottom line is Identifier!=index.

这篇关于AdressBook崩溃,只有一些接触!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆