未找到实例方法'-objectFromJSONString'(返回类型默认为'id')

时间:2013-02-08 21:11:30

标签: objective-c xcode

有人可以帮我解决这个警告吗?

警告:

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

代码:

- (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];
    }
}

1 个答案:

答案 0 :(得分:3)

您需要将JSONKit头文件导入到正在使用它的文件中:

#import "JSONKit.h"