2013-02-08 1 views
1

누군가가 그 경고를 해결하도록 도와 줄 수 있습니까?인스턴스 메소드 '-objectFromJSONString'을 찾을 수 없습니다 (반환 유형의 기본값은 'id'입니다)

경고 :

Instance method '-objectFromJSONString' not found (return type defaults to 'id') 

코드 :

당신은 그것을 사용하고 파일에 JSONKit 헤더 파일을 가져와야합니다
- (void)checkVersion { 
    NSString *version = @""; 

    NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/lookup?id=<Your app ID>"]; 
    ASIHTTPRequest *versionRequest = [ASIFormDataRequest requestWithURL:url]; 
    [versionRequest setRequestMethod:@"GET"]; 
    [versionRequest setDelegate:self]; 
    [versionRequest setTimeOutSeconds:150]; 
    [versionRequest addRequestHeader:@"Content-Type" value:@"application/json"]; 
    [versionRequest startSynchronous]; 

    NSString* jsonResponseString = [versionRequest responseString]; 

    // --> ERROR NEXT LINE 
    NSDictionary *loginAuthenticationResponse = [jsonResponseString objectFromJSONString]; 

    NSArray *configData = [loginAuthenticationResponse valueForKey:@"results"]; 

    for (id config in configData) 
    { 
     version = [config valueForKey:@"version"]; 
    } 

    //Get Current Version 
    NSString *currentVersion=[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]; 
    //Check your version with the version in app store 
    if (![version isEqualToString:currentVersion]) 
    { 
     UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"New Version" 
                 message:@"Download it!" delegate:self 
               cancelButtonTitle:@"Cancel" 
               otherButtonTitles:@"Download", nil] autorelease]; 
     [alert show]; 
    } 
} 
+2

당신은 JSONKit을 포함? – Jeremy

+1

오류? "반환 유형 기본값은 id"인 경우 가장 가능성이 높습니다. –

+0

그래, 경고 야! JSON 클래스를 추가했지만 경고를 계속합니다. –

답변

3

:

#import "JSONKit.h" 
+0

하지만 왜 JSONKit 헤더 파일을 가져 오지 않고도 작동 할 수 있습니까? – why

+0

이 경우 컴파일러는 정확하게 추측했기 때문에 id를 반환합니다. (- (id) objectFromJSONString;) – escrafford

관련 문제