这样写 会crash,莫名奇妙
//NSString* homeAddress = [[NSString alloc ]stringWithFormat:@"%@,%@,%@" ,CFDictionaryGetValue(dict, kABPersonAddressStreetKey) , CFDictionaryGetValue(dict, kABPersonAddressCityKey),CFDictionaryGetValue(dict, kABPersonAddressCountryKey)] ;
这样就不会
NSString* homeAddress = [NSString stringWithFormat:@"%@,%@,%@" ,CFDictionaryGetValue(dict, kABPersonAddressStreetKey) , CFDictionaryGetValue(dict, kABPersonAddressCityKey),CFDictionaryGetValue(dict, kABPersonAddressCountryKey)] ;
CFStringRef firstName, lastName;
firstName = (CFStringRef)ABRecordCopyValue((ABRecordRef)people, kABPersonFirstNameProperty);
lastName = (CFStringRef)ABRecordCopyValue((ABRecordRef)people, kABPersonLastNameProperty);
NSString *tmpName = [NSString stringWithFormat:@"%@%@",
nil == lastName ? @"" : (NSString *)lastName,
nil == firstName ? @"" :(NSString *)firstName];
CFRelease(firstName) ;
CFRelease(lastName) ;
下面这样就不会crash
NSString *firstName = (NSString *)ABRecordCopyValue((ABRecordRef)people, kABPersonFirstNameProperty);
NSString *lastName = (NSString *)ABRecordCopyValue((ABRecordRef)people, kABPersonLastNameProperty);
NSString *tmpName = [NSString stringWithFormat:@"%@%@",
nil == lastName ? @"" : (NSString *)lastName,
nil == firstName ? @"" :(NSString *)firstName];
[firstName release]
[lastName release]