iphone - Read string from a file return nil -


i try read string file :

nsstring* path = [[nsbundle mainbundle] pathforresource:@"dirty" oftype:@"txt"]; nsstring* content = [[nsstring alloc] initwithcontentsoffile:path encoding:nsutf8stringencoding error:&err]; 

and string nil. in error :

error domain=nscocoaerrordomain code=261 "the operation couldn’t completed. (cocoa error 261.)" userinfo=0x21063410 {nsfilepath=/var/mobile/applications/78889f89-b83c-480c-a246-999152ee757c/myapp.app/dirty.txt, nsstringencoding=4} 

any idea problem?

as mentioned, cocoa error 261 nsfilereadinapplicablestringencodingerror means encoding of file different passing in api.

for hebrew language encoding, try this answer

nsstring* content = [[nsstring alloc] initwithcontentsoffile:path encoding:cfstringconvertencodingtonsstringencoding(kcfstringencodingwindowshebrew) error:&err]; 

hope helps!


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -