views:

265

answers:

2

Hi..

I`m working on a project where an alert should pop up after returning from a controller with an empty value. It does pop up in the simulator, but on the iphone the app freeze and exit when returning from the controller. Any ideas?

Here is my code:

  - (void)manualBarcodeViewControllerDidFinish:(ManualBarcodeViewController *)controller
    {

        ......
        ......

        else if([barcode isEqualToString:@""])
        {
         UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"error" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"otherbutton"];
         [alert show];
     [alert release];
         }
     }
+2  A: 

you should look at this question maybe it will help:

uialertview causes crash in release mode

John Stallings
yeah, that was the problem, stupid me :( But thanks!
Madoc
+2  A: 

Your otherButtonTitles argument needs to be nil-terminated.

In general, methods that take a variable number of arguments, need to have nil at the end. For example:

[NSArray arrayWithObjects:objA, objB, nil];

and in your case:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"error" message:@"message" delegate:self cancelButtonTitle:@"cancel" otherButtonTitles:@"otherbutton", nil];
Martin Gordon
yup, that was the problem, thanks :)
Madoc