有人可以帮我解决这个警告吗?
警告:
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];
}
}
答案 0 :(得分:3)
您需要将JSONKit头文件导入到正在使用它的文件中:
#import "JSONKit.h"