Skip to content

Commit

Permalink
criando método no Utils para identificar se a imagem existe no projeto
Browse files Browse the repository at this point in the history
  • Loading branch information
renanvs committed Mar 9, 2014
1 parent 7433084 commit 670d240
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ - (void)dealloc {
//Utiliza as informações do model para popular a célula
-(void)setCategoryModel:(FoodCategoryModel*)categoryModel_{
categoryModel = categoryModel_;
//todo: criar method auxiliar para verificar a existencia de imagens no projeto
if ([categoryModel_.imageName isEqualToString:@"default.png"]) {
if (![Utils existThisImage:categoryModel_.imageName]) {
//gatodo: categoryMode.name sem imagem
categoryModel_.imageName = @"defaultImage.png";
}
Expand Down
2 changes: 2 additions & 0 deletions PaleoProject/PaleoProject/Utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

+(void)debugAlert:(NSString*)message;

+(BOOL)existThisImage:(NSString*)imageName;

@end

@interface NSString (custom)
Expand Down
11 changes: 11 additions & 0 deletions PaleoProject/PaleoProject/Utils/Utils.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ + (Utils *) sharedInstance{
return _instance;
}

#pragma mark - UIImage

//Verifica se existe no projeto, alguma imagem com esse nome
+(BOOL)existThisImage:(NSString*)imageName{
UIImage *image = [UIImage imageNamed:imageName];
if (image) {
return YES;
}
return NO;
}

#pragma mark - NSString auxiliar

//retorna uma NSString minuscula e sem acento
Expand Down
Binary file removed PaleoProject/PaleoProject/images/default
Binary file not shown.

0 comments on commit 670d240

Please sign in to comment.