开发者

I want to pass a variable in CFSTR?

In following coding, i want to pass variable via CFSTR, how can I ?

ABMutableMultiValueRef address = ABMultiValueCreateMutable(kABDictionaryPropertyType);
// Set up keys and values for the dictionary.

CFStringRef keys[5];

CFStringRef values[5];

keys[0] = kABPersonAddressStreetKey;

keys[1] = kABPersonAddressCityKey;

keys[2] = kABPersonAddressStateKey;

keys[3] = kABPersonAddressZIPKey;

keys[4] = kABPersonAddressCountryKey;

values[0] = CFSTR("Wiztech, 208/B Clifton Center, Karachi");

//values[0] = CFSTR(address1); I want to pass address1 which is NSString, how can I?
开发者_如何学运维
values[1] = CFSTR("");

values[2] = CFSTR("");

values[3] = CFSTR("");

values[4] = CFSTR("");


Just cast it like:

NSString * yourThing = [NSString stringWithString:@"blah blah"]
values[0] = (CFStringRef)yourThing;

NSString and CFString are interchangeable (subject to being cast). Dont forget to retain/release too

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜