Posted By

zingo on 02/21/08


Tagged

file cocoa osx


Versions (?)

Saving Data to File


 / Published in: Objective C
 

URL: http://www.cocoabuilder.com/archive/message/cocoa/2003/1/31/77631

  1. - (void)saveDataIntoFile:(NSString*)pFilePath
  2. {
  3. char * pBytes;
  4. unsigned length;
  5.  
  6. length = DATAFILE_LENGTH; //custom define
  7. pBytes = malloc(length);
  8.  
  9. // store your data to pBytes here
  10.  
  11. { // Save to file
  12. NSData * pSaveData = [NSData dataWithBytes:pBytes length:length];
  13. [pSaveData writeToFile:pFilePath atomically:FALSE];
  14. }
  15.  
  16. free(pBytes);
  17. }

Report this snippet  

You need to login to post a comment.