开发者

Warnings with NSString

I have the lines

usernameString = [[NSString alloc] initWithFormat:[username text]];
[username setText:usernameString]; // <--- warning Format not a string literal and no format arguments

username is a UITextField 开发者_运维问答

Tell me if you need anymore info


If you just want to duplicate the string, you can do that using initWithString:, which gives you back a new string with the same contents as the string passed in:

usernameString = [[NSString alloc] initWithString:[username text]];


Try:

usernameString = [[NSString alloc] initWithFormat:@"%@",[username text]];

Don't forget to release usernameString later, if you need to.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜