0

Code works fine in Xcode Simulator, but when I tested it on real device, app hangs with error: EXC_BAD_ACCESS, (code 1, address 0x0)

ABMultiValueRef multi = ABRecordCopyValue(person, kABPersonEmailProperty);
NSString* contactEmail = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(multi, 0);
CFRelease(multi);

Upd.: Works on iPhone also, if contact has email field filled. If not, it crashes.

Shmidt
  • 15,652
  • 16
  • 79
  • 129
  • OK, check for quantity prevents from crashing. if (ABMultiValueGetCount(phones) > 0) { contactPhone = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(multi, 0); } – Shmidt Dec 17 '11 at 17:16

1 Answers1

0

OK, checking for zero prevents from crashing.

if (ABMultiValueGetCount(phones) > 0) {
    contactPhone = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(multi, 0);
}
Shmidt
  • 15,652
  • 16
  • 79
  • 129