ios - Objective C: Reading text files -
i've done before, not working me now. i'm doing:
nsstring* path = [[nsbundle mainbundle] pathforresource:@"test" oftype:@"txt"]; nsstring* content = [nsstring stringwithcontentsoffile:path encoding:nsutf8stringencoding error:null]; nslog(@"%@",path);
and returns (null)
every time when nslog path , content. can see i'm doing wrong?
content nil (which logs '(null)') if pass path can't open. issue relevant instance of nsbundle unable find test.txt within resources part of application bundle.
you should:
- check file in xcode project; and, if is,
- check it's included in 'copy bundle resources' phase underneath selected target (in project tree view on left in normal xcode window layout) and, if is,
- look inside generated application bundle (find product, right click, select 'reveal in finder', finder right click on app , select 'show package contents', file in there) make sure it's there.
if it's copied in relevant instance of nsbundle can't find strange afoot.
Comments
Post a Comment