【发布时间】:2016-03-15 11:40:14
【问题描述】:
我使用地址簿来获取带有标签的联系人列表。 (如移动、主要、家庭、工作、传真等)。我从联系人中获取了电话、电子邮件标签,但我没有获取生日、周年纪念标签。这是我的生日课程代码。
ABMultiValueRef dateofbirth1 = ABRecordCopyValue(contactPerson, kABPersonBirthdayProperty); // Assign the Date Of birth
NSString *dob1=[NSDateFormatter localizedStringFromDate:(__bridge NSDate *)(dateofbirth1) dateStyle:NSDateFormatterLongStyle timeStyle:0]; // Changing to string format using Date Formatter.
if(!(dob1==nil))
{
// DOB is Not Nill
}
这是我获取的生日标签代码
if([arrayOfDatesAsStrings count]>0)
{
for (int j = 0; j < [arrayOfDatesAsStrings count] ; j++)
{
**//This is the fetching birthday label code and following code is crashed**
CFStringRef locLabel1 = ABMultiValueCopyLabelAtIndex((__bridge ABMultiValueRef)(dob1), j);
NSString *phoneLabel1 =(__bridge NSString*) ABAddressBookCopyLocalizedLabel(locLabel1);
personD.dateOfBirth = phone1;
NSLog(@" %@ %@",phoneLabel1,personD.dateOfBirth);
}
}
else
{
NSLog(@"Date Of Birth was Not set ");
}
我可以为此做些什么?谁能帮我?崩溃错误消息是: “线程 1:Exc_BAD_ACCESS(代码=1,地址=0x38)”
【问题讨论】:
-
如果崩溃,错误信息是什么?
-
线程 1:Exc_BAD_ACCESS(代码=1,地址=0x38)
标签: ios objective-c iphone