当我运行我的应用程序并且如果没有互联网连接时,它会直接终止我的应用程序并显示此消息。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil
- (void)viewDidLoad
{
response = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://example.com/jsonTest.php"]];
NSError *parseError = nil;
jsonArray = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingAllowFragments error:&parseError];
jsonArray1 = [[NSMutableArray alloc] init];
for(int i=0;i<[jsonArray count];i++)
{
...
..
.
}
}
我已经尝试下面的代码来显示警报视图但没有显示,我做错了什么吗?
-(void)uploadRequestFailed:(NSJSONSerialization *)request
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"No internet connection" message:@"Please check the internet connection" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}