tags:

views:

34

answers:

2

hi i am new to iPhone.what i did is crating an array with image names like

images = [NSMutableArray alloc] initWithObjets:@"image1.jpg",@"image2.jpg",@"image3.jpg",nil]

i am creating 3 buttons and displaying button images from images array randomly by using random().now i have to compare the images in the array with button image if they are equal then i have to do another funcion to compare the image in Nslog i am writing the code as NSLog(@"image %@",button.imageView.image); i get in console . can any one pls suggest any idea how can i caompare the array and button image.Thank u in advance.

A: 

Not really sure what you need, but if the button was created in code using the images from the array, you can use a simple pointer equality check:

for (UIImage *img in array)
    if (button.imageView.image == img)
        // whatever
zoul
+1  A: 

set the button.tag to match the index in the array of images

[images objectAtIndex: button.tag]

will give you the image associated with the button

Aaron Saunders