Re: Reading/Writing Text files
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