2010-09-29 13 views
6

Meine App stürzt ab, es ist ein Problem, das sich aus der AddressBook API ergibt, es passiert nur bei einigen Kontakten. HierAddressBook Crash, nur mit einigen Kontakten

ist das Protokoll:

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 

Das macht mich verrückt, da es nur mit einer isolierten Anzahl von Kontakten geschieht.

Jede Hilfe würde sehr geschätzt werden.

Hier ist der Code, der angefordert wurde, wir danken Ihnen sehr für Ihre Hilfe:

(Es ist ein Auszug aus dem Verfahren, in dem ich den Fehler denken passiert)

Die seltsame Sache, dass es nur geschieht mit bestimmten Kontakten und den Kontakt zu löschen, dann einen neuen erstellt löst das 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"]; 
+0

Was ist der Eingang, den Sie den Absturz erstellen? Tritt das immer bei bestimmten Kontakten auf? Was ist die Fehlermeldung? – vodkhang

+1

Einschließlich des Codes von '- [CallAppDelegate peoplePickerNavigationController: sollteContinueAfterSelectingPerson: property: identifier:]' wäre sehr hilfreich, vor allem der Code um die Zeile 408 von AppDelegate.m. –

+0

Ich habe den Code, wo ich denke, der Fehler passiert, wäre es ratsam, den gesamten Extrakt mit einem @try @catch wickeln? – Zebs

Antwort

12

Um jemand ein ähnliches Problem auftritt:

Mein Fehler aus der Tatsache kam, dass ich mit:

ABMultiValueCopyValueAtIndex mit einer Kennung anstelle eines Index.

Sie müssen ABMultiValueGetIndexForIdentifier anrufen und dann diesen Index auf ABMultiValueCopyValueAtIndex verwenden.

Die untere Zeile ist Identifier!=index.

0

mir sicher, dass Sie wirklich mit gültigem Mehrwertsatztyp zu tun wäre.

if (ABMultiValueGetPropertyType(phone) != kABInvalidPropertyType) { 
    // Do work here. 
} 

Eigentlich wäre es wahrscheinlich sicherer, um sicherzustellen, dass es wirklich eine Zeichenfolge ist.

if (ABMultiValueGetPropertyType(phone) == kABMultiStringPropertyType) { 
    // Do work here. 
} 

Ich weiß nicht, warum das nicht der Fall wäre. Vielleicht haben Sie Kontakte Einträge korrumpiert? Oder ist die Telefonnummer manchmal nicht ein Multi-Wert-Typ?

2

von Statt

mit

ABMultiValueCopyValueAtIndex(multiValue, identifier);

Welche Zebs oben erwähnt, die Verwendung ...

ABMultiValueCopyValueAtIndex(multiValue, ABMultiValueGetIndexForIdentifier(multiValue, identifier)); 
Verwandte Themen