I read around S.O and did Google this a fair bit but I wasn't able to find an answer to my problem...
I have an NSDictionary which 开发者_运维知识库is returning NSCFString's and what I need is an NSString so that I can use its doubleValue function. I can't for the life of me figure out how to turn my NSCFString's into NSStrings. I've tried the following with no success:
NSString* lng_coord = (NSString*)[dict objectForKey:key];
if ([lng_coord class] == [NSString class])
NSLog(@"lng coord is an exact match with NSString class");
else {
NSLog(@"lng coord doesn't match NSString class");
NSLog(@"The class of lng_coord is %@", [[dict objectForKey:key] class]);
}
NSLog(@"%@", lng_coord);
[CelebsAnnotation setLongitude:[lng_coord doubleValue]];
And this is the output from console:
lng coord doesn't match NSString class
The class of lng_coord is NSCFString
49.2796758
NSCFString is a private subclass of NSString, you can just use it as one.
Because of such patterns like class clusters, you shouldn't directly compare the classes here - use -isKindOfClass: instead:
if ([lng_coord isKindOfClass:[NSString class]]) {
// ...
加载中,请稍侯......
精彩评论