首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >[__NSCFString timeIntervalSinceReferenceDate]:未识别的选择器发送到ABRecordSetValue中的实例0x6c2ccb0

[__NSCFString timeIntervalSinceReferenceDate]:未识别的选择器发送到ABRecordSetValue中的实例0x6c2ccb0
EN

Stack Overflow用户
提问于 2013-08-12 06:14:47
回答 1查看 2.2K关注 0票数 0

__NSCFString timeIntervalSinceReferenceDate:未识别的选择器发送到实例0x6c2ccb0

当我试图在通讯录中放置联系人时,我的代码中出现了这个错误。感谢任何解决方案

代码语言:javascript
复制
     NSArray *names=[test componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
        NSLog(@"Count:%d,%d",[names count],[test length],[names objectAtIndex:0],[names objectAtIndex:1] );
        //Works fine, a sample output-> For String:John Smith ; Count:2,10,John,Smith

        //CFStringRef temp; //for troubleshooting

    switch([names count])
    {
     case 1:ABRecordSetValue(self.person12,kABPersonFirstNameProperty,(__bridge_retained CFTypeRef)([names objectAtIndex:0]), NULL);
                                break;
     case 2: // Error occurs in case 2 as count is 2
     {

      //Commented region is what I tried out as an alternative but didnt work
     /*temp=(__bridge_retained CFTypeRef)((NSString*)[names objectAtIndex:0]);
                                ABRecordSetValue(self.person12,kABPersonFirstNameProperty,(CFTypeRef)temp,NULL);

    temp=(__bridge_retained CFStringRef)((NSString*)[[names objectAtIndex:1] substringToIndex:[[names objectAtIndex:1] length]-1]);
                               ABRecordSetValue(self.person12,kABPersonLastNameProperty,temp,NULL);*/

ABRecordSetValue(self.person12,kABPersonFirstNameProperty,(__bridge CFTypeRef)([names objectAtIndex:0]),NULL);// Error occurs after the execution of breakpoint here

ABRecordSetValue(self.person12,kABPersonLastNameProperty,(__bridge CFTypeRef)([[names objectAtIndex:1] substringToIndex:[[names objectAtIndex:1] length]-1]),NULL);
     break;
      }



    default:
       {
    ABRecordSetValue(self.person12,kABPersonFirstNameProperty,(__bridge_retained CFTypeRef)([names objectAtIndex:0]),NULL);
                                ABRecordSetValue(self.person12,kABPersonMiddleNameProperty,(__bridge_retained CFTypeRef)([names objectAtIndex:1]),NULL);
                                test=@"";
         for(int j=2;j<[names count];j++)
              test=[test stringByAppendingString:[names objectAtIndex:j]];

        test=[test substringToIndex:[test length]- 1];
                                ABRecordSetValue(self.person12,kABPersonLastNameProperty,(__bridge_retained CFTypeRef)test,NULL);
         break;
       }
     }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-12 09:36:06

初始化ABRecordRef

呃,

代码语言:javascript
复制
self.person12=ABPersonCreate();

也是

初始化通讯簿

代码语言:javascript
复制
self.addressBook=ABAddressBookCreate();

这会解决问题的!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18180583

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档