views:

349

answers:

4
char asd='a';
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Are you sure?" message:asd
               delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[alert show];
[alert release];

above code not compiling in iPhone simulator. Why is that? :)

A: 
  1. You don't compile in the iPhone simulator, you compile on your mac.
  2. Do you get an error message?
  3. The message parameter should be an NSString, not a char?
ongle
A: 

replace

char asd='a';

With

NSString *asd=@"a";

It should compile after it...

mihirpmehta
+1  A: 

You're trying to pass a char where an NSString is expected. Read up on Objective-C and th Cocoa/Cocoa Touch documentation.

To fix your issue, try this:

NSString *asd = @"a";
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Are you sure?" message:asd
               delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
Jasarien
A: 

Thank you very much. :)

paul
You should mark one of the answers (the one you found most useful would do) as accepted by clicking the checkmark next to the answer.
ongle