0

This is my code:

    ABAddressBookRef _addressBookRef = ABAddressBookCreate ();
    NSArray* allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(_addressBookRef);
    NSMutableArray* _allItems = [[NSMutableArray alloc] initWithCapacity:[allPeople count]]; // capacity is only a rough guess, but better than nothing
  for (id record in allPeople) {
        CFTypeRef phoneProperty = ABRecordCopyValue((ABRecordRef)record, kABPersonPhoneProperty);
        NSArray *phones = (NSArray *)ABMultiValueCopyArrayOfAllValues(phoneProperty);
        CFRelease(phoneProperty);
        for (NSString *phone in phones) {
            NSString* compositeName = (NSString *)ABRecordCopyCompositeName((ABRecordRef)record);
            NSString* field = [[NSString] stringWithFormat@"%@:%@",compositeName,phone];            
            [compositeName release];
            [_allItems addObject:field];
            for ( NSString *txt in _allItems )
            {
                contacts.text = [contacts.text stringByAppendingFormat:@"%@\n",txt];
            }
        }
        [phones release];
    }


    CFRelease(_addressBookRef);
    [allPeople release];
    allPeople = nil;

}

i basically want to dump the entire addressbook into a UItextView called contacts.text and have just the name and number like this NAME:NUMBER seperated by the :. i am currently getting a error on the line

 NSString* field = [NSString stringWithFormat@"%@:%@",compositeName,phone];

any help would be awesome :D

Thanks Mason

user393273
  • 1,430
  • 5
  • 25
  • 48
  • /Users/hobbypunk/Desktop/Copy Whole Address Book/Classes/MainViewController.m:80:0 /Users/hobbypunk/Desktop/Copy Whole Address Book/Classes/MainViewController.m:80: error: expected ':' before ']' token – user393273 Jul 21 '10 at 19:36

1 Answers1

0
 NSString* field = [NSString stringWithFormat@"%@:%@",compositeName,phone];

should be

 NSString* field = [NSString stringWithFormat:@"%@:%@",compositeName,phone];
Maulik
  • 19,348
  • 14
  • 82
  • 137
user393273
  • 1,430
  • 5
  • 25
  • 48