I am trying to load names in an array using UIAlert and then print them one by one. I am not able to figure this out, c开发者_高级运维an anyone help me out with this? I would really appreciate your help.
NSArray *array = [NSArray arrayWithObjects:@"One", @"Two", @"Three", @"Four", nil];
for (NSString *element in array)
{
// Log to console..
NSLog(@"element: %@", element);
//Show in alert.. Really??
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"ALERT TITLE" message:element delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
NSArray *array = [NSArray arrayWithObjects:@"One",@"Two",@"Three",nil];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"ALERT TITLE" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
for(NSInteger index=0; index<[array count]; index++)
{
[alert addButtonWithTitle:[array objectAtIndex:index]];
}
精彩评论