nsstring - Comparing 2 strings in Objective-C -


i have nstask of output stored in nsdata object. string via

nsstring *outputstring = [[nsstring alloc] initwithdata:outputdata encoding:nsutf8stringencoding];

now can nslog string , compare via [outputstring isequaltostring:@"nslogged string"]. result 2 strings not identical. why that? played encoding not seem problem.

the output tool contains trailing newline character. either compare against "yourexpectedstring\n" or use like

outputstring = [outputstring stringbytrimmingcharactersinset:[nscharacterset newlinecharacterset]; 

to remove newline characters.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -