Alterplay / APAddressBook

Easy access to iOS address book
MIT License
1.38k stars 193 forks source link

Urgent : Message from debugger: Terminated due to memory issue #152

Closed skparticles closed 7 years ago

skparticles commented 7 years ago

I have also tried 0.3.1 version with test device iPhone 6sPlus, It is crashing on loading contacts. I have no idea, why it is crashing.

[self.addressBook loadContactsOnQueue:queue completion:^(NSArray<APContact *> *contacts, NSError *error) {
}];
belkevich commented 7 years ago

May be you try to load contact images? Please, provide more code.

skparticles commented 7 years ago
APAddressBook *addressBook = [[APAddressBook alloc] init];
addressBook.fieldsMask = APContactFieldAll;
addressBook.sortDescriptors = @[
 [NSSortDescriptor sortDescriptorWithKey:@"name.firstName" ascending:YES],
 [NSSortDescriptor sortDescriptorWithKey:@"name.lastName" ascending:YES]
];

dispatch_queue_t queue = dispatch_queue_create("background task", NULL);
[addressBook loadContactsOnQueue:queue completion:^(NSArray<APContact *> *contacts, NSError *error) {
   //Crashing
}];
belkevich commented 7 years ago
dispatch_queue_t queue = dispatch_queue_create("background task", NULL);

Try to store queue in property. Also, if you call some UI-interacting methods in completion block, the app can crash. Use main queue to fix this

skparticles commented 7 years ago

Thanks.

belkevich commented 7 years ago

Feel free to reopen this issue if you still have problems