iphone - NSMutableString appendFormat... adds spaces? -
iphone - NSMutableString appendFormat... adds spaces? -
when trying append nsmutablestring appendformat - adds spaces.
nsm nsmutablestring, att_1_variable & att_2_variable nsstring
[nsm appendformat:@"<tagname att_1=\" %@ \" att_2=\" %@ \">", att_1_variable, att_2_variable];
the result is:
<tagname myattribute=" contentofvariable " title=" contentofvariable ">
before passing in strings doing:
nsstring* att_1_variable = [att_1_variable_orginal stringbytrimmingcharactersinset: [nscharacterset whitespaceandnewlinecharacterset]];
is there way around this?
thanks regards christian
you're adding spaces yourself, including them in format string. in c escape sequence quotation mark \"
, no trailing (or leading) space. want:
[nsm appendformat:@"<tagname myattribute=\"%@\" title=\"%@\">", attributevariable, titlevariable];
if there spaces between quotation marks , variable contents after input variables padded spaces. can trim like:
nsstring *trimmedattributevariable = [attributevariable stringbytrimmingcharactersinset:[nscharacterset whitespacecharacterset]]; ... [nsm appendformat:@"<tagname myattribute=\"%@\" title=\"%@\">", trimmedattributevariable, ...
which trim spaces , tabs both ends.
iphone ios nsstring
Comments
Post a Comment