StringWithFormat creates a string with gibberish characters

When debugging the following code

NSString *var1 = @"blaa";
NSString *var2 = @"blaaaaa";

NSString* script = [NSString stringWithFormat:@"Set_Variable( %s, %s )",var1,var2]; 

placeholders %sin the script are replaced with funny lyric characters. Do you see errors in the code?

+3
source share
1 answer

% s - format specifier for string C, char *

For objective-c objects (such as NSString) you should use% @

+11
source

Source: https://habr.com/ru/post/1703027/


All Articles