Closed spidergears closed 9 years ago
I am trying to load address book
self.addressBook.loadContacts( { (contacts: [APContact]?, error: NSError? ) in self.contactList = [] if (contacts != nil) { for contact in contacts!{ for contactNumber in contact.phones! { let contact = Contact.new(contact.name?.firstName, lastName: contact.name?.lastName, contactNumber: contactNumber.number, thumbnail: contact.thumbnail ?? UIImage() ) if (contact != nil){ //append contact to list self.contactList.append(contact!) } } } onCompletion(self.contactList) } else if (error != nil) { //handle error } })
this fails with error: * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<APContact 0x60c000d40e00> valueForUndefinedKey:]: this class is not key value coding-compliant for the key firstName.' * First throw call stack: ( 0 CoreFoundation 0x0000000104a5bf65 exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000106ceddeb objc_exception_throw + 48 2 CoreFoundation 0x0000000104a5bba9 -[NSException raise] + 9 3 Foundation 0x00000001050dbe8c -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 226 4 Foundation 0x0000000105031f37 -[NSObject(NSKeyValueCoding) valueForKey:] + 280 5 Foundation 0x00000001050479c2 _sortedObjectsUsingDescriptors + 363 6 Foundation 0x00000001050a10e2 -[NSMutableArray(NSKeyValueSorting) sortUsingDescriptors:] + 470 7 APAddressBook 0x0000000103652ae6 -[APContactListBuilder sortContacts:] + 470 8 APAddressBook 0x0000000103651ea1 -[APContactListBuilder contactListWithAllContacts:] + 577 9 APAddressBook 0x000000010363edc3 __48-[APAddressBook loadContactsOnQueue:completion:]_block_invoke_3 + 1011 10 APAddressBook 0x0000000103655137 -[APThread performBlock:] + 423 11 Foundation 0x0000000105064607 NSThreadPerformPerform + 283 12 CoreFoundation 0x00000001049880a1 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 13 CoreFoundation 0x000000010497dfcc CFRunLoopDoSources0 + 556 14 CoreFoundation 0x000000010497d483 CFRunLoopRun + 867 15 CoreFoundation 0x000000010497ce98 CFRunLoopRunSpecific + 488 16 Foundation 0x0000000105068891 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 267 17 APAddressBook 0x0000000103654f54 -[APThread main] + 212 18 Foundation 0x000000010510636b NSThread__start + 1198 19 libsystem_pthread.dylib 0x000000010895905a _pthread_body + 131 20 libsystem_pthread.dylib 0x0000000108958fd7 _pthread_body + 0 21 libsystem_pthread.dylib 0x00000001089563ed thread_start + 13 ) libc++abi.dylib: terminating with uncaught exception of type NSException
You have error in sortDescriptors property. Share it's value
sortDescriptors
Thanks that worked. I was not using the new APName class when specifying sortDescriptors.
I am trying to load address book
this fails with error: * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<APContact 0x60c000d40e00> valueForUndefinedKey:]: this class is not key value coding-compliant for the key firstName.' * First throw call stack: ( 0 CoreFoundation 0x0000000104a5bf65 exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000106ceddeb objc_exception_throw + 48 2 CoreFoundation 0x0000000104a5bba9 -[NSException raise] + 9 3 Foundation 0x00000001050dbe8c -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 226 4 Foundation 0x0000000105031f37 -[NSObject(NSKeyValueCoding) valueForKey:] + 280 5 Foundation 0x00000001050479c2 _sortedObjectsUsingDescriptors + 363 6 Foundation 0x00000001050a10e2 -[NSMutableArray(NSKeyValueSorting) sortUsingDescriptors:] + 470 7 APAddressBook 0x0000000103652ae6 -[APContactListBuilder sortContacts:] + 470 8 APAddressBook 0x0000000103651ea1 -[APContactListBuilder contactListWithAllContacts:] + 577 9 APAddressBook 0x000000010363edc3 __48-[APAddressBook loadContactsOnQueue:completion:]_block_invoke_3 + 1011 10 APAddressBook 0x0000000103655137 -[APThread performBlock:] + 423 11 Foundation 0x0000000105064607 NSThreadPerformPerform + 283 12 CoreFoundation 0x00000001049880a1 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 13 CoreFoundation 0x000000010497dfcc CFRunLoopDoSources0 + 556 14 CoreFoundation 0x000000010497d483 CFRunLoopRun + 867 15 CoreFoundation 0x000000010497ce98 CFRunLoopRunSpecific + 488 16 Foundation 0x0000000105068891 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 267 17 APAddressBook 0x0000000103654f54 -[APThread main] + 212 18 Foundation 0x000000010510636b NSThread__start + 1198 19 libsystem_pthread.dylib 0x000000010895905a _pthread_body + 131 20 libsystem_pthread.dylib 0x0000000108958fd7 _pthread_body + 0 21 libsystem_pthread.dylib 0x00000001089563ed thread_start + 13 ) libc++abi.dylib: terminating with uncaught exception of type NSException