Can I have multiple UIAlertViews for one IBAction in Xcode?

In your . H: interface MyViewController : UIViewController { NSArray *messages; } @property (nonatomic, retain) NSArray *messages In your . M implementation MyViewController @synthesize messages; - (dealloc) { messages release; } - (void)viewDidLoad { messages = NSArray alloc initWithObjects:@"Funny Message", @"Even Funnier Message", @" @"ROFL", @"OK this is getting boring...", nil; } When you need an alert: NSUInteger messageCount = messages count; int randomMessageIndex = arc4random() % messageCount; UIAlertView *alert = UIAlertView alloc initWithTitle:@"Title" message:messages objectAtIndex:randomMessageIndex delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil; alert show; alert release.

In your . H: @interface MyViewController : UIViewController { NSArray *messages; } @property (nonatomic, retain) NSArray *messages; In your . M @implementation MyViewController @synthesize messages; - (dealloc) { messages release; } - (void)viewDidLoad { messages = NSArray alloc initWithObjects:@"Funny Message", @"Even Funnier Message", @" @"ROFL", @"OK this is getting boring...", nil; } When you need an alert: NSUInteger messageCount = messages count; int randomMessageIndex = arc4random() % messageCount; UIAlertView *alert = UIAlertView alloc initWithTitle:@"Title" message:messages objectAtIndex:randomMessageIndex delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil; alert show; alert release.

– cory ginsberg Aug 12 at 1:31 declare messages in your . H - see updated question – Alex Coplan Aug 12 at 7:34 When I run the code, the program works for one question, but it then crashes and shows the error "Program received signal: "EXC_BAD_ACCESS"" What am I doing wrong? I have copy and pasted your code so I know that it's all typed correctly.

– cory ginsberg Aug 12 at 13:54 never mind I figured it out... – cory ginsberg Aug 12 at 15:14.

Define the following macro for the project: for the msg section as try a Array with random Index #define KAlert(TITLE,MSG) UIAlertView alloc initWithTitle:(TITLE) message:(MSG) delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil autorelease show Which could be used as simple call: KAlert(@"Title", @"Message"); or KAlert(@"Title",@"youarray objectatindex:randindex").

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions


Thank You!
send