I am loading some text from xml and an image, that image takes longer to load than the xml, but I want to show them at the same time.
I am loading the image using
NSData *mydata = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:imgLink]];
How can I set a callback function that lets me know that mydata has the image, so I can add both the image and the text to the view?
Thanks
You will have to use NSURLConnection. This is fairly straightforward, but more involved than the NSData method.
First, create an NSURLConnection:
Now, add <NSURLConnectionDelegate> to the header of your class and implement the following methods:
The first one should append the data, as shown below, and the final one should create and display the image.
See this document for more details.