1

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

警告:

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

1 回答 1

3

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

#import "JSONKit.h"
于 2013-02-08T21:27:10.040 回答