We Recommend

Programming in Objective-C Programming in Objective-C
Programming in Objective-C is a concise, carefully written tutorial on the basics of Objective-C and object-oriented programming. The book makes no assumption about prior experience with object-oriented programming languages or with the C language (upon which Objective-C is based). And because of this, both novice and experienced programmers alike can use this book to quickly and effectively learn the fundamentals of Objective-C.


Ballyhoo


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.