0

I Got MutableArray Like Following

 - @"6 objects"
 - [0]=(_NSDictionary*) 4 key/Value pairs
  - [0]=@"Home":@"(555)564-8583"
  - [1]=@"Mobile":@"(415)555-3695"
  - [2]=@"First Name":@"Kate"
  - [3]=@"Last Name":@"Bell"
 - [1]=(_NSDictionary*) 5 key/Value pairs
 - [2]=(_NSDictionary*) 5 key/Value pairs
 - [3]=(_NSDictionary*) 5 key/Value pairs
 - [4]=(_NSDictionary*) 5 key/Value pairs

Now I Want To Display My TableView Like following

  • Kate Bell
    • (555)564-8583
    • (415)555-3695
  • John Appleseed
  • Hank Zakroff
  • David Taylor
  • Daniel Higgins

In Above TableView Kate Bell Is Expanded And Other All Are Collapsed.It Mean When We Tap On Contact Name At That Time Numbers Will Display And Another Tap It Will Hide.

I am Putting Code By Which I get Mutable Array named (allcontact) Like Above.

- (void)getAllContacts {

    //[self getPermissionForContacts ];
NSString *homeno,*mobileno,*workno;

    CFErrorRef *error = NULL;
    ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(NULL, error);



    CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
    CFIndex numberOfPeople = ABAddressBookGetPersonCount(addressBook);

    for(int i = 0; i < numberOfPeople; i++) {

        ABRecordRef person = CFArrayGetValueAtIndex( allPeople, i );

        NSString *firstName = (__bridge NSString *)(ABRecordCopyValue(person, kABPersonFirstNameProperty));
        NSString *lastName = (__bridge NSString *)(ABRecordCopyValue(person, kABPersonLastNameProperty));
        NSLog(@"Name:%@ %@", firstName, lastName);

        ABMultiValueRef phoneNumbers = ABRecordCopyValue(person, kABPersonPhoneProperty);

        for (CFIndex i = 0; i < ABMultiValueGetCount(phoneNumbers); i++) {
            NSString *phoneNumber = (__bridge_transfer NSString *) ABMultiValueCopyValueAtIndex(phoneNumbers, i);
            NSLog(@"phone:%@", phoneNumber);
            if (i==0) {
                homeno=phoneNumber;
            } else if (i==1) {
                mobileno=phoneNumber;
            }else if (i==2) {
                workno=phoneNumber;
            }
        }


         allContactDict = [[NSDictionary alloc] initWithObjectsAndKeys:
                                     firstName,@"First Name",
                                        lastName,@"Last Name",
                                        homeno,@"Home",
                                        mobileno,@"Mobile",
                                        workno,@"Work",nil];


        [allContact addObject:allContactDict];


        homeno=@"";
        mobileno=@"";
        workno=@"";
        NSLog(@"=============================================");

    }

}

enter image description here enter image description here

I Want My TableView Like Above Image. Thanx In Advance

Rahul Patel
  • 5,858
  • 6
  • 46
  • 72

0 Answers0