• 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: 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


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

  • Prev by Date: Re: how to implement xmlhttprequest in posting data
  • Next by Date: Re: Re: Speaking of tracking rects...
  • Previous by thread: Re: Reading/Writing Text files
  • Next by thread: Re: Reading/Writing Text files
  • Index(es):
    • Date
    • Thread