开发者

iPhone Development xcode : Putting user input (names) into text array

开发者 https://www.devze.com 2022-12-12 10:04 出处:网络
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 he

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]];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消