Skip to content

Commit

Permalink
First check local folder and then try to load the remote images
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeswang committed Jan 22, 2015
1 parent b890086 commit a5519df
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Hearthstone-Deck-Tracker/Controllers/CardPreviewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ - (void)viewDidLoad {

- (void)loadCardByCardId:(NSString *)cardId {

//NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:HEARTHHEAD_IMAGE_TEMPLATE, cardId]];
//[self.cardImage setImage:[NSImage imageNamed:@"Card_back-Default"]];
//[self.cardImage setImageURL:imageURL];

NSString *imageFilePath = [NSString stringWithFormat:LOCAL_IMAGE_TEMPLATE, cardId];
[self.cardImage setImage:[[NSImage alloc] initWithContentsOfFile:imageFilePath]];
NSFileManager *fm = [NSFileManager defaultManager];
if ([fm fileExistsAtPath:imageFilePath]) {
[self.cardImage setImage:[[NSImage alloc] initWithContentsOfFile:imageFilePath]];
}
else {
NSURL *imageURL = [NSURL URLWithString:[NSString stringWithFormat:HEARTHHEAD_IMAGE_TEMPLATE, cardId]];
[self.cardImage setImage:[NSImage imageNamed:@"Card_back-Default"]];
[self.cardImage setImageURL:imageURL];
}
}

@end

0 comments on commit a5519df

Please sign in to comment.