Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Once you have finished using <code>addressBook</code> you need to release it using:</p> <pre><code>CFRelease(addressBook); </code></pre> <p>This should probably be placed at the end of your <code>viewWillAppear:</code> method.</p> <p><strong>Updated:</strong> There are a few unnecessary arrays and steps in your version of <code>viewWillAppear:</code>. I have cleaned it up a bit and fixed a potential memory leak. </p> <p>Note: I haven't actually run this so double-check that it works correctly.</p> <pre><code>- (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; // I assume m_tableDataArray is an instance variable. If so, if the // view appears multiple times it will result in a leak unless we // release pre-existing instances first. [m_tableDataArray release], m_tableDataArray = nil; m_tableDataArray = [[NSMutableArray alloc] init]; ABAddressBookRef addressBook = ABAddressBookCreate(); NSArray *addresses = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook); for (ABRecordRef record in addresses) { NSString *firstName = (NSString *)ABRecordCopyValue(record, kABPersonFirstNameProperty); NSString *lastName = (NSString *)ABRecordCopyValue(record, kABPersonLastNameProperty); if(firstName != nil &amp;&amp; lastName != nil){ NSString *contactFirstLast = [NSString stringWithFormat: @"%@ %@", firstName, lastName]; [m_tableDataArray addObject:contactFirstLast]; } [firstName release]; [lastName release]; } [addresses release], addresses = nil; CFRelease(addressBook); [m_mainTable reloadData]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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