有人可以帮我解决该警告吗?未找到实例方法'-objectFromJSONString'(返回类型默认为'id')
警告:
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];
}
}
您包括JSONKit? – Jeremy 2013-02-08 21:15:31
错误?如果“返回类型默认为id”,那么它很可能是一个警告。 – 2013-02-08 21:19:38
是的,这是一个警告!我添加了JSON类,但继续警告。 – 2013-02-08 21:20:49