Hi,
The exception message in the title has been bugging my code for a while. It only occurred 70% of the time. I also tried to isolate the problem in a small project to post it here and guess what, it didn’t occur (so can it be a memory related thing).
There is no stacktrace, just the following message in the log:
libc++abi.dylib: terminating with uncaught exception of type ObjCException
By placing a lot of logging I managed to find the lines where it broke. I have tried to put try catch blocks around everything to catch it, but the entire program just freezes and you cannot do anything anymore.
This is my code:
private void selectContacts(Set<String> alreadyExistingPlayers, CNContactStore contactStore) {
// TODO: Handle the error. Currently everything I tried to do with the error object didn't work though...
Ptr<NSError> error = PtrFactory.newObjectReference(NSError.class);
// TODO: Also retrieve the last name. But for some reason that results in an ObjCException so I sticked with only the first name now...
NSArray<?> keysToFetch = NSArray.arrayWithObject(Contacts.CNContactGivenNameKey());//, Contacts.CNContactFamilyNameKey());
CNContactFetchRequest request = CNContactFetchRequest.alloc().initWithKeysToFetch(keysToFetch);
// TODO: Figure out why we keep getting the "libc++abi.dylib: terminating with uncaught exception of type ObjCException"
contactStore.enumerateContactsWithFetchRequestErrorUsingBlock(request, error, new CNContactStore.Block_enumerateContactsWithFetchRequestErrorUsingBlock() {
@Override
public void call_enumerateContactsWithFetchRequestErrorUsingBlock(CNContact contact, BoolPtr stop) {
String name = contact.givenName(); // + contact.familyName();
if (!(name.length() == 0) && !alreadyExistingPlayers.contains(name)) {
names.add(name);
/***************************
* If I add any code here to add the name directly to the UI, we sometimes get an ObjCException.
***************************/
someUILabel.setText(name); // CRASH
}
}
});
}
Do you guys see anything wrong with my code?
I have found a work around for this so this is not a high priority thing for me. I can provide a full sample to reproduce it if necessary.
PS: I use the moe 1.3.8, gradle plugin 1.3.12 and libgdx 1.9.6 and I test on an iPhone 5s