我在 ios 7 的 iphone 联系人中保存了生日日期,但代码在 ios 5 中不起作用。还有其他方法吗?
ABAddressBookRef addressBook = ABAddressBookCreate();
ABRecordRef person = ABPersonCreate();
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]];
[dateFormat setDateFormat:@"dd MMM yyyy"];
NSDate * birdayDate =[dateFormat dateFromString:contactCardBirthdateLbl.text];
NSArray * nameArray = [contactCardNameLbl.text componentsSeparatedByString:@" "];
ABRecordSetValue(person, kABPersonFirstNameProperty,(__bridge CFTypeRef)([nameArray objectAtIndex:0]) , nil);
ABRecordSetValue(person, kABPersonLastNameProperty,(__bridge CFTypeRef)([nameArray objectAtIndex:1]), nil);
ABRecordSetValue(person, kABPersonJobTitleProperty,(__bridge CFTypeRef) contactCardOccupationLbl.text, nil);
ABRecordSetValue(person, kABPersonBirthdayProperty,(__bridge CFDateRef)birdayDate,nil);