Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS Simulator does not show permission alert
    text
    copied!<p>My app uses Address Book framework. To show all contacts in iOS 6 or higher I have to set permission for it.</p> <p>At first time when I was running my app on the simulator I saw this alert below, but when I try to show it again I don't see the alert one more time.</p> <p><img src="https://i.stack.imgur.com/Cgvl8.jpg" alt="enter image description here"></p> <p>I have reseted content and settings but it has not helped me. So when I rerun app it all time shows contacts, but at first the app has to show alert when I reseted simulator. Anybody faced with this issue?</p> <p>Code below:</p> <pre><code>- (void)getPersonOutOfAddressBook { if (self.tableData) { [self.tableData removeAllObjects]; } ABAddressBookRef addressBook = ABAddressBookCreate(); __block BOOL accessGranted = NO; if (ABAddressBookRequestAccessWithCompletion != NULL) { // we're on iOS 6 dispatch_semaphore_t sema = dispatch_semaphore_create(0); ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) { accessGranted = granted; dispatch_semaphore_signal(sema); }); dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); dispatch_release(sema); } else { // we're on iOS 5 or older accessGranted = YES; } if (accessGranted) { if (addressBook != nil) { NSLog(@"Succesful."); NSArray *allContacts = (__bridge_transfer NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook); NSUInteger i = 0; for (i = 0; i &lt; [allContacts count]; i++) { Contact *contact = [[Contact alloc] init]; ABRecordRef contactPerson = (__bridge ABRecordRef)allContacts[i]; NSString *firstName = (__bridge_transfer NSString *)ABRecordCopyValue(contactPerson, kABPersonFirstNameProperty); NSString *lastName = (__bridge_transfer NSString *)ABRecordCopyValue(contactPerson, kABPersonLastNameProperty); NSString *fullName = [NSString stringWithFormat:@"%@ %@", firstName, lastName]; NSData *imgData = (__bridge NSData *)ABPersonCopyImageData(contactPerson); contact.firstName = firstName; contact.lastName = lastName; contact.fullName = fullName; contact.image = [UIImage imageWithData:imgData]; [self.tableData addObject:contact]; } CFRelease(addressBook); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload