Hello I got an issue with this
for (NSString* fileName in fileList){
if ( [fileName rangeOfString:@".png"].location != NSNotFound ) {
int x= col*130;
NSLog(@"add %@", fileName);
//create dynamically a nice thumbnail
UIImage* img = [UIImage imageWithContentsOfFile:
[self.documentsDir stringByAppendingPathComponent:fileName]
];
UIImageView* imgView = [[UIImageView alloc] initWithImage:img];
imgView.frame = CGRectMake(0, 0, 110, 110);
imgView.contentMode = UIViewContentModeScaleAspectFill;
imgView.clipsToBounds = YES;
UIButton* imgBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[imgBtn addTarget:self action:@selector(imgPressed:) forControlEvents:UIControlEventTouchUpInside];
imgBtn.frame = CGRectMake(x, row*130, 120, 120);
//imgBtn.backgroundColor = [UIColor lightGrayColor];
[imgBtn addSubview:imgView];
[self.canvas addSubview:imgBtn];
[imgView release];
col++;
if (x > 760) {
row++;
col = 0;
}
}
this makes really nice thumbnail, but i want to make it with only files with specific name, so i have problem how to load only the specific name types. like e.g. I have images named …city1,city2,city3, all are types png, and i also have car1,car2 …. also png. But once I want to load only cities and once only cars….
Is there any possibility to load only cities or only cars????
Thanks to all.
I don’t know how to make the exact comparison to string.
I would use something like this
if(filename isequaltoString:@”car%”)
but it doesn’t work.. =(
You already have code to almost handle this…
You just need to check for @”car” or whatever you are looking for, and you can’t just check the location property or NSRange, because if you match at the first character index 0 your test above will fail.
You should check length as well.