Reputation: 17
Hi If you have an array that stores images and text then displays the content in a random manner how can you check to know that the element about to be retrieved contains an image or text so that if an image I display a UIMageView and if text I display a UILabel
thanks.
Upvotes: 0
Views: 176
Reputation: 3733
Assuming your text is always an instance of NSString and your images are always instances of UIImage:
for (id obj in mixedArray) {
if ([obj isKindOfClass:[NSString class]])
// display via UILabel
else if ([obj isKindOfClass:[UIImage class]])
// display via UIImageView
}
Upvotes: 3