2011-03-02 2 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

SBJSON 대신 SBJsonParser를 사용 했으므로 이제는 정상적으로 작동합니다. 어쩌면 그것은 제가 가지고있는 iOS 버전과 관련이있을 것입니다 ..

0

그것은이 라인이다 :

#import <JSON/JSON.h> 

당신은 a JSON framework를 가져 오기 위해 노력하고 있지만이 설치되어 있지 않습니다.

+0

나는 그것을 설치해야합니다. 또한 NSLog (@ "JSON : % @", [@ "[1,2,3, true, false, null]"JSONValue]를 파싱했습니다. 모든 것이 잘 작동하는 것 같습니다. 또한 SBJSON을 입력하면 편집기에서 단어 자동 완성 기능을 제공합니다. – developer

관련 문제