tags:

views:

1027

answers:

1
imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:srcAddres]];

Downloading jpeg to my imagedata will spend some time,for example: 2 second, so I want to show an activity indicator until the downloading finished. How can I know when the downloading has finished??

+4  A: 

Use this version of the method:

- (id)initWithContentsOfURL:(NSURL *)aURL options:(NSUInteger)mask error:(NSError **)errorPtr

Make sure you pass in an NSError pointer by declaring one before you make the call:

NSError *error

...and then passing the error as:

&error

If error is not nil then you have a problem. You can then inspect the error to give proper user feedback. I won't go into the mask here. You can read all about this method in the documentation.

hyuan