Reputation: 333
I am new to objective C and I am in a position where I need to create an iPhone App Really quickly , I am using XCode 4.2
I want to have a pop up and I am using this code :
in the .h I have
#import <AddressBook/AddressBook.h>
#import <AddressBookUI/AddressBookUI.h>
and in the .m file
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Confirmation"
message:@"confirmed"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil,nil];
[alert show];
the code shows me a building error "Expected identifier" , did I forget something ?
Thanks
Upvotes: 0
Views: 239
Reputation: 23500
You have two errors :
->[<-
[[UIAlertView alloc] initWithTitle:@"Confirmation"
message:@"confirmed"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil->,nil<-]
;
delete them and just write :
[[UIAlertView alloc] initWithTitle:@"Confirmation"
message:@"confirmed"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
If you are not using ARC, don't forget to release [alert release]
after [alert show]
(or autorelease
at the end of the init)
Upvotes: 0
Reputation: 1931
You have an extra open bracket '['
you need something like this:
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Confirmation"
message:@"confirmed"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil] autorelease];
[alert show];
Note the autorelease] code I added, this way you set to autorelease the UIAlertView and fix the extra open bracket.
Upvotes: 1