I am new to iOS programming and I have a conceptual and a functional question. I tried looking at SO threads but did not get an exact question matching my situation.
I am building a simple screen where I display a list of user names along with their avatars - something like your typical Contacts screen.
I am using a UITableview
for this purpose.
I first make a HTTP GET call to retrieve the list of users which returns a JSON with their names and the url to download their image. I then will store this info into Core Data and cache the images as well.
I am struggling with the part where I download the images and set it into the UIImageView.image
.
- Conceptually, which method should I use to get the names and the image urls -
viewDidLoad
orviewWillAppear
? It seems to me that I should useviewWillAppear
as in subsequent calls, I will be getting the list from Core Data and there is no network activity? tableView:cellForRowAtIndexPath
is the function that I use to get the image corresponding to each row. Is this correct?
Any help or pointing towards a duplicate question will help much! Thanks!