• 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: Reading/Writing Text files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading/Writing Text files


  • Subject: Re: Reading/Writing Text files
  • From: John Stiles <email@hidden>
  • Date: Mon, 11 Sep 2006 06:52:01 -0700

You can certainly use the old-school approach that you're probably already familiar with:

   FILE *f = fopen( [myPathInAnNSString fileSystemRepresentation], "rb" );

There are some good Objective-C ways to do it as well, but honestly I think fopen works well enough for reading raw text :)


email@hidden wrote:
Slightly frustrated here. What I need to do is this...

I need to read in text files off a PC, manipulate some bytes of data and then write the data back out to plain text files. How do I do this? It seems every Cocoa application example I look at assumes that you want to use an encoder, so all I can find are examples of reading and writing with encoders.

I just want to.

1: Read in the text file into an NSTextView
2: Have the user make some minor changes
3: Write the new data back out (To a Plain text file)

Is this possible??

Here is what I have so far... just so you have an idea of what I'm trying to do

- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)type
{
// Let's see what we're getting...
NSLog(@"loadDataRepresentation: %@: %@",type, data);
NSAttributedString *tempString = [data description];
[self setString:tempString];
if ([self string] != nil)
{
[[myTextView textStorage] setAttributedString: [self string]];
}
return YES; }
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Reading/Writing Text files (From: email@hidden)

  • Prev by Date: Re: Re: Speaking of tracking rects...
  • Next by Date: Re: Reading/Writing Text files
  • Previous by thread: Re: Reading/Writing Text files
  • Next by thread: Re: Reading/Writing Text files
  • Index(es):
    • Date
    • Thread