Iphone 如何在创建新联系人时设置社交档案属性
在我的应用程序中,我正在创建一个ABRecordRef实例并创建一个新联系人。所以我试着用这些代码来设置社交档案iDIphone 如何在创建新联系人时设置社交档案属性,iphone,ios,ipad,Iphone,Ios,Ipad,在我的应用程序中,我正在创建一个ABRecordRef实例并创建一个新联系人。所以我试着用这些代码来设置社交档案iD ABMutableMultiValueRef fbvalue = ABMultiValueCreateMutable(kABMultiStringPropertyType); ABMultiValueAddValueAndLabel(fbvalue, (__bridge CFTypeRef)[linedevidebydel objectAtIndex:linedevidebyde
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'
谁能帮我一下吗。。。提前感谢您您需要使用dictionary with property作为社交档案属性,使用方式如下:,
希望这对你有帮助
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);