• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: creating files to write data to?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: creating files to write data to?


  • Subject: Re: creating files to write data to?
  • From: Jason Coco <email@hidden>
  • Date: Fri, 15 Aug 2008 18:43:55 -0400


On Aug 15, 2008, at 18:10 , FTB Accounts wrote:

Devon, thanks for your response. However, your suggestion still does not make the code work. No data is written to the file.

/* WRITE DATA TO FILE: THIS IS A TEST */
	[fh writeData:@"THIS IS A TEST"];
	[fh closeFile];

I simply was copying the advice given on a previous post. I have tried just about everything and can get nothing to work? has anyone on this list ever had success in writing to a local file, and if so can you show me the code you used?

Adding the @ just makes it an NSString constant... but writeData still requires (NSData *), not (NSString *). As was pointed out before, are you sure that you have
write permissions here? You should check your errors... also, try writing the location with basic system calls (just to test briefly) and check the return result and the
errno to see what might be the issue...?


Following up on what another poster suggested, is it possible to do this another way? For instance, if you are storing strings and binary data, is it possible to
write this file using an (NSMutableDictionary *)? You could write both your strings (NSString *) and data (NSData *) to a structure in memory (if you don't have keyed data, just use (NSMutableArray *) instead of (NSMutableDictionary *). If you're afraid of losing data or have to share the data through the file, maybe you could flush it every
time you make a change? Both the array and the dictionary respond to - (BOOL)writeToFile:(NSString *)path atomically:(BOOL)flag


/jason

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: creating files to write data to?
      • From: Andy Lee <email@hidden>
References: 
 >Re: creating files to write data to? (From: FTB Accounts <email@hidden>)

  • Prev by Date: Re: Making a bound view re-read its value
  • Next by Date: Re: creating files to write data to?
  • Previous by thread: Re: creating files to write data to?
  • Next by thread: Re: creating files to write data to?
  • Index(es):
    • Date
    • Thread