-2

我正在使用此代码

NSDictionary *yourDictionary;

NSArray * yourKeys;
yourKeys = [yourDictionary allValues];

获取字典的值。但我希望以这种形式输出数组:array[0],array[1],而我在控制台中获得如下输出:-

2013-01-12 18:44:10.213 Birthday_Reminder[2871:c07] (
{
},
"Arpit Sihare")

等等值。所以请帮助我以这种形式获取这些值,并且我正在使用 KABPersonfirstnameproperty 从通讯簿中检索这些名称。

  ABAddressBookRef addressBook = ABAddressBookCreate();
    NSArray *thePeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook);
    NSMutableArray* allPeoplesDicts = [NSMutableArray array];
    for (id person in thePeople)
    {
        ABMultiValueRef phone =(NSString*)ABRecordCopyValue(person, kABPersonPhoneProperty);
        NSString* name = (NSString *)ABRecordCopyCompositeName(person);
       // NSMutableArray* phones = [[NSMutableArray alloc] init];
        NSDictionary *phones=[[NSDictionary alloc]init ];
        for (CFIndex i = 0; i < ABMultiValueGetCount(phones); i++)
        {
            NSString *phone = [(NSString *)ABMultiValueCopyValueAtIndex(phones,i) autorelease];
            [phones addObject:phone];
        }
        NSDictionary* personDict = [[NSDictionary alloc] initWithObjectsAndKeys:name,@"Name",phones,@"PhoneNumbers",nil];
        [phones release];


        NSArray * yourKeys;
        yourKeys = [personDict allValues];


        NSLog(@"%@",yourKeys);
        [allPeoplesDicts addObject:personDict];
        [personDict release];
    }

我想要数组形式的名字,当我使用 nslog(@"%@",array[0]) 它应该首先打印存储在数组中的值,很快就会像数组 [1]....

4

1 回答 1

0

很难理解你想说什么。我试过了,发现...

如果您只想存储所有firstName(我认为这是您的密钥),那么只需制作yourKeys一个NSMutableArray并将其添加names到该数组中。:

[yourKeys addObject:names];

简单的 !!

于 2013-01-12T13:47:56.380 回答