views:

114

answers:

1

I am new to iphone development.I am creating a map application.Now i am facing a problem with the alert view.To see how alert view displayed in simulator, i have added a alert view in the "view did load "method.When i click a button in the landing page it navigates to another view(where alert view is displayed)When i run the app ,in console window i can see the session started once again after the initial start at landing page.

for displaying the alert

 UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Current Location" message:@"Show Current Location?" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK"];
    [alert show];

IN the console window

  [Session started at 2010-02-18 15:57:12 +0530.]

[Session started at 2010-02-18 15:57:23 +0530.]
GNU gdb 6.3.50-20050815 (Apple version gdb-967) (Tue Jul 14 02:11:58 UTC 2009)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 604.
(gdb) 

I just wanted to see alert view without doing any action on clicking ok or cancel buttons.Please help me out. please guide me.Thanks.

+1  A: 

That's just the debugger (gdb) initialising.

If the debugger isn't started on app launch (which will be the case if you just build and run instead of build and debug) the debugger will start and initialise when the app encounters a problem.

The problem you have here is in your alert view init line. Everything is fine until the last parameter: otherButtonTitles: - notice the plural on titles, not title. This means the parameter takes a nil-terminated list of items - this is also stated in the documentation.

you should amend your code so that parameter is nil-terminated like so:

 UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Current Location" message:@"Show Current Location?" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
Jasarien
Thanks.It was working fine.Where should i write the code for click "ok" event which should load the current location
Warrior
That is a separate topic, so you should ask a new question for that.A hint is to look at the `UIAlertViewDelegate` protocol.
Jasarien