我正在尝试保存kABFirstNamePropert,kABLastNameProperty和kABAddressProperty全部保存到一个数组中以便以后调用,我只是没有得到它,任何人都可以借给我一个指针或指向正确的方向吗?谢谢。我是一个超级NOOb。
为命名字符串:
// setting the first name
firstName.text = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
// setting the last name
lastName.text = (NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty);
用于设置addressLabel:
NSString *address;
address = [NSString stringWithFormat:@"%@, %@, %@, %@ %@",
[theDict objectForKey:(NSString *)kABPersonAddressStreetKey],
[theDict objectForKey:(NSString *)kABPersonAddressCityKey],
[theDict objectForKey:(NSString *)kABPersonAddressStateKey],
[theDict objectForKey:(NSString *)kABPersonAddressZIPKey],
[theDict objectForKey:(NSString *)kABPersonAddressCountryKey]];
self.addressLabel.text = address;
保存数组:我所拥有的不起作用。 ;(
- (IBAction)saveData {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *recipient = [NSString stringWithFormat:@"%@/arraySaveFile", documentsDirectory];
NSMutableArray *array = [[NSMutableArray alloc] init];
[array addObject:firstName];
[array addObject:lastName];
[array addObject:addressLabel];
[array writeToFile:recipient atomically:NO];
}
答案 0 :(得分:1)
此:
[array addObject:firstName];
需要:
[array addObject:firstName.text];
谢谢大家。