开发者

Call NSString in UIAlertView?

hey I'm coding using theos and I want the value of an NSString to display inside of the fields on the UIAlertView below, how would i go about writing that? here it is:

UIAlertView *quickreply = [[UIAlertView alloc] initWithTitle:@"%@" message:@"%@" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:@"Reply", nil];

I've tried writing a , NSStringID after the qu开发者_开发问答otes but it gives errors for the entire UIAlertView, so idk how I'm supposed to code it, am i supposed to use brackets or more quotes within the quotes, or parenthesis' or what?

please help


stringWithFormat is what you want, try this:

NSString *title = [NSString stringWithFormat:@"title is %@", @"my title"];
NSString *msg = [NSString stringWithFormat:@"message is %@", @"my message"];
UIAlertView *quickreply = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Close" otherButtonTitles:@"Reply", nil];


Use:

[NSString stringWithFormat:@"%@", theString];

if you want to do it that way. Hope that helps!


NSString *message = [NSString stringWithFormat:@"%@",myIvar];

set the message of the UIAlertView to the message NSString

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜