0

在我的应用程序中,我正在创建一个 ABRecordRef 实例并创建一个新联系人。所以我尝试了这些代码行来设置社交资料 iD

ABMutableMultiValueRef fbvalue = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(fbvalue, (__bridge CFTypeRef)[linedevidebydel objectAtIndex:linedevidebydel.count - 1], kABPersonSocialProfileServiceFacebook, NULL);
ABRecordSetValue(newPerson, kABPersonSocialProfileProperty, fbvalue,nil);
            CFRelease(fbvalue);

但在最后一行出现错误

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString count]: unrecognized selector sent to instance 0x17631380'

任何人都可以帮助我...提前谢谢你

4

1 回答 1

1

你需要使用带有属性的字典作为社交资料属性,像这样使用,

   ABMutableMultiValueRef multiSocial =  ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
   NSMutableDictionary *socialDictionary = [[NSMutableDictionary alloc]init]; //use this for other profile, twitter, linkedIn , etc 

  [socialDictionary setObject:@"happy.coding@ymail.com" forKey:(NSString *) kABPersonSocialProfileServiceFacebook];

  ABMultiValueAddValueAndLabel(multiSocial, socialDictionary, kABPersonSocialProfileServiceFacebook, NULL);
  ABRecordSetValue(newPerson, kABPersonAddressProperty, multiSocial,&error);


希望这对你有帮助

于 2013-09-06T10:59:49.600 回答