2011-03-02 51 views
1

我得到「SBJSON」未申報(第一次在這個函數中使用)錯誤,當我嘗試運行下面的一段代碼。「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。

回答

4

我用SBJsonParser代替SBJSON,現在工作得很好。或許這是與iOS版本我對..

0

這是這一行:

#import <JSON/JSON.h> 

你試圖導入a JSON framework,但你沒有安裝它。

+0

我有它安裝。我還與測試的NSLog它(@ 「經分析的一些JSON:%@」,[@ 「[1,2,3,TRUE,FALSE,空]」 JSONValue]);一切似乎都很好。此外,當我鍵入SBJSON編輯器確實給我的自動完成功能的字.. – developer 2011-03-02 22:57:22

相關問題