问题
iOS8 introduced a new scheme for configuring ABPeoplePicker using NSPredicates. I need more than the a basic predicate for which people to enable so I tried using predicateWithBlock like so:
- (NSPredicate *)predicateForEnablingPerson
{
return [NSPredicate predicateWithBlock:^BOOL(id evaluatedObject, NSDictionary *bindings)
{
return TRUE; // Just pass back true until we figure out why it's crashing
}];
}
There's nothing in the scant documentation about this not being supported. Anyone know why this doesn't work?
thread #1: tid = 0x4b596e, 0x049cea6b libobjc.A.dylib`objc_exception_throw, name = 'MAINTHREAD-1412492637.228968-5', queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
frame #0: 0x049cea6b libobjc.A.dylib`objc_exception_throw
frame #1: 0x04e0bd1d CoreFoundation`+[NSException raise:format:] + 141
frame #2: 0x03fadf0a Foundation`-[NSBlockPredicate encodeWithCoder:] + 59
frame #3: 0x03ed9219 Foundation`-[NSXPCEncoder _encodeObject:] + 665
frame #4: 0x03eeab49 Foundation`-[NSXPCEncoder _encodeArrayOfObjects:forKey:] + 299
frame #5: 0x03ebe0a4 Foundation`-[NSDictionary(NSDictionary) encodeWithCoder:] + 1273
frame #6: 0x03ed9219 Foundation`-[NSXPCEncoder _encodeObject:] + 665
frame #7: 0x03eeab49 Foundation`-[NSXPCEncoder _encodeArrayOfObjects:forKey:] + 299
frame #8: 0x03ebe0a4 Foundation`-[NSDictionary(NSDictionary) encodeWithCoder:] + 1273
frame #9: 0x03ed9219 Foundation`-[NSXPCEncoder _encodeObject:] + 665
frame #10: 0x03ed88c6 Foundation`-[NSXPCEncoder encodeObject:forKey:] + 135
frame #11: 0x03ed9611 Foundation`-[NSXPCEncoder encodeObject:] + 48
frame #12: 0x03ecd082 Foundation`_walkAndEncodeData + 1286
frame #13: 0x03ecca8c Foundation`encodeInvocationArguments + 612
frame #14: 0x03ed93dc Foundation`-[NSXPCEncoder encodeInvocation:] + 406
frame #15: 0x03ed9219 Foundation`-[NSXPCEncoder _encodeObject:] + 665
frame #16: 0x03ed88c6 Foundation`-[NSXPCEncoder encodeObject:forKey:] + 135
frame #17: 0x03ed7c30 Foundation`-[NSXPCConnection _sendInvocation:proxyNumber:remoteInterface:withErrorHandler:timeout:userInfo:] + 2910
frame #18: 0x03ee3668 Foundation`-[NSXPCConnection _sendInvocation:proxyNumber:remoteInterface:withErrorHandler:] + 95
frame #19: 0x03ee35f9 Foundation`-[_NSXPCDistantObjectWithError forwardInvocation:] + 133
frame #20: 0x04d5c78e CoreFoundation`___forwarding___ + 478
frame #21: 0x04d5c58e CoreFoundation`__forwarding_prep_0___ + 14
frame #22: 0x017515f4 AddressBookUI`-[CNContactPickerExtensionHostContext setupWithOptions:readyBlock:] + 312
frame #23: 0x01750fca AddressBookUI`-[CNContactPickerHostViewController setupWithOptions:readyBlock:] + 166
frame #24: 0x0166f4e5 AddressBookUI`-[CNContactPicker _setupViewController] + 1179
frame #25: 0x0166f024 AddressBookUI`-[CNContactPicker _setViewController:] + 447
frame #26: 0x0166f9a1 AddressBookUI`__41-[CNContactPicker _prepareViewController]_block_invoke116 + 72
frame #27: 0x01750ddc AddressBookUI`__55+[CNContactPickerHostViewController getViewController:]_block_invoke + 340
frame #28: 0x0322167e UIKit`__117-[NSExtension(UIViewControllerAdditions) instantiateViewControllerWithInputItems:listenerEndpoint:connectionHandler:]_block_invoke_3 + 129
frame #29: 0x033723aa UIKit`__124+[_UIRemoteViewController _requestViewController:traitCollection:fromServiceWithBundleIdentifier:service:connectionHandler:]_block_invoke_2 + 107
frame #30: 0x0528e41a libdispatch.dylib`_dispatch_call_block_and_release + 15
frame #31: 0x052aee1f libdispatch.dylib`_dispatch_client_callout + 14
frame #32: 0x05295981 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 610
frame #33: 0x04d65f3e CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14
frame #34: 0x04d24d40 CoreFoundation`__CFRunLoopRun + 2256
frame #35: 0x04d241ab CoreFoundation`CFRunLoopRunSpecific + 443
frame #36: 0x04d23fdb CoreFoundation`CFRunLoopRunInMode + 123
frame #37: 0x0661d24f GraphicsServices`GSEventRunModal + 192
frame #38: 0x0661d08c GraphicsServices`GSEventRun + 104
frame #39: 0x02c8de16 UIKit`UIApplicationMain + 1526
* frame #40: 0x00002775 SmartRoam`main(argc=3, argv=0xbfffe4a4) + 565 at main.m:42
frame #41: 0x052daac9 libdyld.dylib`start + 1
来源:https://stackoverflow.com/questions/26200502/predicatewithblock-as-the-predicate-for-abpeoplepicker-predicateforenablingperso