Possible Duplicate:
App crash on 4.0 but not on 5.0
In My iPhone App need to download image form server so using this code but this working fine on simulator(iOS 5.1) but not on real device (iOS 4.2).please have a look.
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(5, 5, 260, 160)];
NSURL *imageURL = [NSURL URLWithString:@"http://myImageURL.com/image.png"];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
dispatch_async(dispatch_get_main_queue(), ^{
imageView.image = [UIImage imageWithData:imageData];
});
});
[self.view addSubview:imageView];
This is the third time I’ve answered this same question…
DISPATCH_QUEUE_PRIORITY_BACKGROUNDis only available on iOS 5.0+App crash on 4.0 but not on 5.0