• 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: Questions about retain
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Questions about retain


  • Subject: Re: Questions about retain
  • From: Sherm Pendley <email@hidden>
  • Date: Fri, 27 Dec 2002 15:19:13 -0500

On Friday, December 27, 2002, at 02:54 PM, Ted Lowery wrote:

Is this better?

Assuming that my guess about your intentions was correct - that is, that you wanted to add to body rather than replace it - yes, the new code does that.

Anything leaking here?

Not that I can see.

[body appendFormat:@"<area shape=%cRECT%c coords=%c", 34, 34, 34];

A minor nit about the above. There's nothing wrong with it - it will work. But, it might be easier to escape quotes using backslashes, like this:

[body appendString: @"<area shape=\"RECT\" coords=\""];

The difference is primarily one of style, but there's bit of a performance difference as well. Using a constant string will be a bit faster than evaluating a format. The difference is tiny, though - you won't notice it unless the code is getting called many thousands of times.

NSMutableString* s = [[NSMutableString alloc] init];
[s appendString:header];
[s appendString:body];
[s appendString:footer];
[textView setString:s];
[s release];

Another minor nit. Whenever you find yourself creating an object and releasing it within the scope of the same method, it's often better to use an autoreleased object instead - that way, you can't forget to release it. I would write the above as:

NSString *s = [NSString stringWithFormat: @"%@%@%@", header, body, footer];
[textView setString: s];

Again, though - The code you posted will work fine as-is. These nits are more about style than functionality. Use or ignore them as you wish. :-)

sherm--

UNIX: Where /sbin/init is Job 1.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Questions about retain
      • From: email@hidden
References: 
 >Re: Questions about retain (From: Ted Lowery <email@hidden>)

  • Prev by Date: PB File Template Tokens
  • Next by Date: Re: setting window attributes
  • Previous by thread: Re: Questions about retain
  • Next by thread: Re: Questions about retain
  • Index(es):
    • Date
    • Thread