当我尝试运行下面的代码时,我得到'SBJSON'未声明(在此函数中首次使用)错误。
#import "RootViewController.h"
#import <JSON/JSON.h>
@implementation RootViewController
#pragma mark -
#pragma mark View lifecycle
- (void)viewDidLoad {
[super viewDidLoad];
NSString *myRawJson=[[NSString alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://myserver/jsondata.php"]];
if([myRawJson length]==0)
{
[myRawJson release];
return;
}
SBJSON *parser=[[SBJSON alloc]init];
list = [[parser objectWithString:myRawJson error:nil]copy];
[parser release];
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
请有人帮忙吗?我使用的是SDK 4.2。
答案 0 :(得分:4)
我使用SBJsonParser而不是SBJSON,现在工作正常。也许它与我正在使用的iOS版本有关..
答案 1 :(得分:0)