在我的应用程序中,我正在创建一个ABRecordRef实例并创建一个新联系人。所以我尝试了这些代码行来设置社交档案iD&#39>
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'
任何人都可以帮助我......先谢谢你
答案 0 :(得分: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);
希望这有助于你