objective c - iPhone: Reading a string from a file is returning the wrong results -


what i'm doing:

i reading data off file several times while app runs. use following code so:

nsstring *datapath = [[[nsbundle mainbundle] resourcepath] stringbyappendingpathcomponent:@"data.txt"]; nsstring *data = [nsstring stringwithcontentsoffile:datapath encoding:nsstringencodingconversionexternalrepresentation error:null]; nsarray *components = [data componentsseparatedbystring:@"|||||"]; 

the first time called, works expected - array of length 5, each section containing relevant string.

what goes wrong:

this file never modified. yet, when call same procedure second time (or third, fourth etc) don't same result. instead, array of length 1 returned, containing part of necessary data.

why? can't see reason go wrong... appreciated!

since file in appbundle means can't modify file @ all. sure that, ever code called, autorelease object retained correctly?

if call block of code every time want data, might idea save results of first time , use every time. speed things bit.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -