iPhone SDK simple alert message question
char asd='a';
UIAlertView *alert = [[UIAlertView allo开发者_JAVA技巧c] 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? :)
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];
- You don't compile in the iPhone simulator, you compile on your mac.
- Do you get an error message?
- The message parameter should be an
NSString
, not achar
?
replace
char asd='a';
With
NSString *asd=@"a";
It should compile after it...
精彩评论