ios objective c help with array please!
im new to programming and im trying to make my first iphone app. basically what my app needs to do is draw a random image from an array and output it to a UIImageView in a view. it should be really simple but i cant find anywhere on the in开发者_如何学Pythonternet how to output the array to the uiimage
theArray = [[NSArray alloc] initWithObjects:@"one.png",@"two.png",@"three.png",nil];
heres a basic code of the images. any help would be greatly appreciated!!
also if you could explain any other details i might need.
find a random array index using -
int randomArrIndex = arc4random() % [arr count];
then you can fetch image name from array with this index
UIImageView *imgView = [[UIImageView alloc] initWithImage:[arr objectAtIndex:randomArrIndex]];
精彩评论