开发者

Warnings with NSString

开发者 https://www.devze.com 2023-02-06 18:55 出处:网络
I have the lines usernameString = [[NSString alloc] initWithFormat:[username text]]; [username setText:usernameString]; // <--- warning Format not a string literal and no format arguments

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

精彩评论

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

关注公众号