Posted By

giftederic on 05/16/10


Tagged

textmate


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

umang_nine
rvachere
cnathan


Read Files from the Application Bundle


 / Published in: Objective C
 

  1. // Read in and store as stringNSString*file =[[NSBundle mainBundle] pathForResource:@"jsonTest" ofType:@"txt"];
  2. NSString*str =[NSString stringWithContentsOfFile:file
  3. encoding:NSUTF8StringEncoding error:NULL];
  4. debug(@"str: %@", str);
  5.  
  6. // Do something with the test data...
  7.  
  8. // Read in and store as raw data bytesNSString*file2 =[[NSBundle mainBundle] pathForResource:@"data" ofType:@"txt"];
  9. NSData*data =[NSData dataWithContentsOfFile:file2];

Report this snippet  

You need to login to post a comment.