[英]iPhone SDK simple alert message question
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. 以上代码无法在iPhone模拟器中编译。 Why is that?
这是为什么? :)
:)
You're trying to pass a char
where an NSString
is expected. 您正在尝试传递一个预期使用
NSString
的char
。 Read up on Objective-C and th Cocoa/Cocoa Touch documentation. 阅读Objective-C和Cocoa / Cocoa Touch文档。
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];
NSString
, not a char
? NSString
,而不是char
? replace 更换
char asd='a';
With 用
NSString *asd=@"a";
It should compile after it... 它应该在之后编译...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.