我从JSON中得到了值,它给出了异常变量不是CFString。下面是我从中获取data http://www.krsconnect.no/community/api.html?method=categories&appid=620&mainonly=true的链接
NSString *test = aBook.catId;
Book类
@interface Book : NSObject {
NSString *catId;
NSString *name;}
@property(nonatomic,retain)NSString*catId;
@property(nonatomic,retain) NSString *name;
@end
#import "Book.h"
@implementation Book
@synthesize catId,name;
-(id)init{
self=[super init];
}
- (id)initWithDictionary:(NSDictionary*) dict {
self.catId = [dict valueForKey:@"categoryId"];
self.name = [dict valueForKey:@"name"];
return self;
}
- (void)dealloc {
[catId release];
[name release];
[super dealloc];
}
@end发布于 2011-08-25 14:33:56
它可能是一个整数。使用这个。
NSString* test = [NSString stringWithFormat:@"%d",aBook.catId];发布于 2011-08-25 14:34:28
我想这个问题应该对你有帮助。
Replace multiple characters in a string in Objective-C?
CFStringRef aCFString = (CFStringRef)aNSString;完美而透明地工作。同样:
NSString *aNSString = (NSString *)aCFString;https://stackoverflow.com/questions/7185974
复制相似问题