objective c - NSLog prints a string different to the NSString with format -


this i'm baffled by: when initialize string format 2 different variables this

order *o = [orders objectatindex:i]; nsstring *line = [[nsstring alloc] initwithformat:(@"%@;%@\n", [o _length], [o _amount])]; 

and print out

nslog(@"%@", line); 

it shows this:

tableviewtest[4812:123250] 200 

which wrong. if same doing this

nslog(@"%@;%@\n", [o _length], [o _amount]); 

it comes out this:

tableviewtest[4812:123250] 120cm;200 

which how i'd want line be. why happening? need in same format line can write text file later.

edit:

_length , _amount @property nsstring *_length in order-class. orders nsmutablearray houses data nstableview, data put in nscomboboxes , nstextfields. compiler gives warning: format string not string literal (potentially insecure).

instead of
nsstring *line = [[nsstring alloc] initwithformat:(@"%@;%@\n", [o _length], [o _amount])];,
use
nsstring *line = [nsstring stringwithformat:@"%@;%@\n", [o _length], [o _amount]];


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -