Read Files from the Application Bundle

/ Published in: Objective C
Save to your folder(s)

Copy this code and paste it in your HTML
  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);
  6. // Do something with the test data...
  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


RSS Icon Subscribe to comments

You need to login to post a comment.