I am wanting to be able to view my app offline and all the images in my table. Currently all my images get cached. But not the actual table of results.
NSMutableArray *images;
- (void)viewDidLoad
{
NSURL *url = [NSURL URLWithString:@"http://xxxxxxx.co.uk/jsonimages.php"];
NSData *jsonData = [NSData dataWithContentsOfURL:url];
NSError *error = nil;
if (jsonData) {
NSDictionary *result = [NSJSONSerialization JSONObjectWithData:jsonData
options:NSJSONReadingMutableContainers error:&error];
images = result[@"images"];
}
}
So that gives me a list of image urls, which I then have on my table like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableCell";
SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
[cell.thumbnailImageView setImageWithURL:[NSURL URLWithString:encodedString]
placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
}
Which caches encodedString
using SDWebimage
But if I go onto the app without any access to the internet no images appear. Is this because I need to cache the array?