'SBJSON'未声明(首次使用此功能)

时间:2011-03-02 22:53:19

标签: iphone json ios4

当我尝试运行下面的代码时,我得到'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。

2 个答案:

答案 0 :(得分:4)

我使用SBJsonParser而不是SBJSON,现在工作正常。也许它与我正在使用的iOS版本有关..

答案 1 :(得分:0)

就是这一行:

#import <JSON/JSON.h>

您正尝试导入a JSON framework,但尚未安装。