Re: iphone large image downloading
Re: iphone large image downloading
- Subject: Re: iphone large image downloading
- From: David Duncan <email@hidden>
- Date: Wed, 11 Aug 2010 13:49:54 -0700
On Aug 11, 2010, at 12:46 AM, SanthoshKumarGundu wrote:
> Can any one have an idea of what is the maximum image limit(size and resolution) in iphone?.
>
> There are some images in web server. In my application , I am getting these as NSData (one image at a time) and displaying the image using the following code
>
> NSData *imageData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imageURLString]];
> UIImage *sampleImage = [UIImage imageWithData:imageData];
>
> This is working fine for small images ( upto 1MB of size and resolution of 1024*1024).
>
> But for large images ( 3MB size and resolution of 2500*2500), the application is getting crashed.
What kind of crash are you getting? I would bet that the exception code is 0x8badf00d (see TN2151 for information on what that means and how to read crash reports).
You are actually pretty lucky that the first version works at all, and I bet that if you are on a slow or broken network that it won't work and you will get a similar crash.
Generally any using -initWithContentsOfURL: for remote URLs will fail if you are trying to do so on the main thread (and if you are using UIKit, you are probably trying to do so on the main thread, like the above code).
The correct solution here is to use asynchronous networking to download the data and once you finish the download you can create a UIImage from the gathered data. Using synchronous networking (like you are above) is generally discouraged.
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden