I have 5 images in array which are displaying in UIimageview and displaying one by one .I want to get imagedata on particular image clicked and show some data in webview using touch event.I m not getting imagedata.My code is here
imgarr->includes 5 different images
obj=[touches anyObject];
CGPoint point=[obj locationInView:self.view];
touchLocation=point;
if(CGRectContainsPoint([imgview frame],point))
{
//cloud.center=touchLocation;
NSData *imgData = UIImageJPEGRepresentation(imgview.image, 9.0);
UIImage *img = [UIImage imageWithData:imgData];
NSLog(@"selimg=%@",img);
for(int i=0;i<[imgarr count];i++)
{
UIImage *arr=[imgarr objectAtIndex:i];
NSData *arrdata=UIImageJPEGRepresentation(arr,9.0);
if(arrdata==imgData)
NSLog(@"True");
}
}
Help me..
If you compare to object with
==you are comparing the pointers not the objects value.NSDatahas anisEqualToData:method to check if an object is equal to it self: