2012-12-24 5 views
1

이전에 IOS 5를 실행하고 있던 프로젝트가있었습니다. IOS 4.3에서 프로젝트를 실행하도록했습니다. 프로젝트를 실행할 때 다음과 같은 작성된 방법으로 2 개의 오류가 발생합니다.
오류가 발생했습니다. 이에 대한 가능한 해결책 .Iphone을 처음 사용합니다. 친절하게 도움 :)IOS 4.3에서는 NSJSONSerialization이 작동하지 않습니다.

이 메서드는 서버 의 응답을 구문 분석하고 응용 프로그램의 모델 표현으로 변환합니다.

+ (NSArray*) parseResponse:(NSData *) data { 
    NSDictionary* json = nil; 
Class jsonSerializationClass = NSClassFromString(@"NSJSONSerialization"); 
    if (data) { 
    json = [NSJSONSerialization // error: Use of undeclared identifier 
           // 'NSJSONSerialization' 
      JSONObjectWithData:data 
      options:kNilOptions 
      error:nil]; 
    } 
    NSLog(@"Total contacts fetched: %u",[json[@"contacts"] count]); 
    NSMutableArray *contacts =[[NSMutableArray alloc] init]; 
    for (NSInteger i=0;i<[json[@"contacts"] count];i++){ //error: Array subscript is not 
                //interger 
    NSLog(@"Name %@ ",json[@"contacts"][i][@"lastName"]); 
    Contact *aContact=[[Contact alloc]initWithFirstName:json[@"contacts"][i] 
     [@"firstName"] 
              andLastName:json[@"contacts"][i] 
     [@"lastName"] 
               andEmail:json[@"contacts"][i][@"email"] 
     andPhone:json[@"contacts"][i][@"phone"]]; 
    [contacts addObject:aContact]; 
    } 
    return contacts; 
    } 

답변