Re: Reading/Writing Text files
Re: Reading/Writing Text files
- Subject: Re: Reading/Writing Text files
- From: Nir Soffer <email@hidden>
- Date: Mon, 11 Sep 2006 16:00:55 +0300
Do not use description to get a string. It is just a way to represent
objects for debugging.
Basically you create a string from the data with
initWithData:encoding:, insert into your text view, and save back the
data using dataUsingEncoding:.
The find the docs for these methods, open Xcode, select Help >
Documentation and use the search box.
Also some errors you should fix:
On Sep 11, 2006, at 3:29 PM, email@hidden wrote:
- (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)type
{
// Let's see what we're getting...
NSLog(@"loadDataRepresentation: %@: %@",type, data);
NSAttributedString *tempString = [data description];
tempString is now NSString, not NSAttributedString.
[self setString:tempString];
if ([self string] != nil)
{
[[myTextView textStorage] setAttributedString: [self
string]];
Since you work with plain text, you don't need to set an attributed
string. Use:
[[[myTextView textStorage] mutableString] setString:[self string]];
}
return YES;
}
You always return YES, ignoring errors
You should read the docs about NSString, NSMutableString and Cocoa
text system.
Best Regards,
Nir Soffer
_______________________________________________
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