I'm adding imageDataObject in imagesArray.
ImageData *imageDataObject = [[ImageData alloc]initWithImageId:[[imageListArray objectAtIndex:indexPath.row]imageId]
imageName:[[imageListArray objectAtIndex:indexPath.row] imageName]
image:[UIImage imageWithData:imageData]];
[imagesArray addObject:imageDataObject];
I want to avoid adding imageDataObject if it already exists in imagesArray. imageDataObject is duplicate if imageId is already in the imagesArray object. imageId is string value coming from URL.
I tried containsObject but it's not working.
I know there are similar questions but nothing works for me.
please help.
imageDataObjectthe same? Just because twoimageDataObjecthold the same image or imageName doesn't make them the same (in terms ofcontainsObject). They just have the same contents.NSMutableOrderedSetinsteadSetwould be your best option. This answer may help you