Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

KardelSharpeye

macrumors member
Original poster
Apr 28, 2009
56
0
Good morning all,

Let say i have:
Code:
NSArray imageNames = [NSArray arrayWithObjects:[UIImage imageNamed:"image1.png"], [UIImage imageNamed:"image2.png"]];

NSMutableArray imageViews = [[NSMutableArray alloc] init];

for( i=0; i < [imageNames count]; i++) {
  UIImageView *tempImage = [[UIImageView alloc] initWithImage:[imageNames  objectAtIndex:i]];

  [imageViews addObject:tempImage];
}

is there anyway i can track down which: image1.png or image2.png, i just clicked?
 
Keep an array of the UIImageViews (in the same order as the UIImages) and check which UIImageView the message comes from. UIImages don't keep track of which file (or URL) they come from. I suppose because you can create images from raw data...
 
i dont understand. i do have an array of UIImageViews its NSMutableArray and i dont see any method in the API to compare the names
 
i dont understand. i do have an array of UIImageViews its NSMutableArray

So you do. So you just need to check which one is sending the message. Each touch event has a view property which tells you which view sent the message. Just iterate over the array of UIImageViews checking if they are equal to this property. That will tell you the index if the touched image.
 
yeah i know i can check if the object touched is contained in the array but after finding out which index or object it is, i was just wondering if i can find out its name(image1.png, image2.png, etc..).
 
Did you read my post? UIImages don't track that. You need to use the index from the UIImageView array to lookup the name in an array of your own with the file names.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.