On Jul 12, 2009, at 8:16 AM, William Squires wrote:
- (void)setWebView:(SomeAppDelegate *)appDelegate
{
NSString *htmlString;

htmlString = @"<div style=\"font-family;Helvetica,Arial, sans-serif; font-size=48pt;\"align=\"center\">"; htmlString = [htmlString stringByAppendingString:appDelegate.savedNumber];
htmlString = [htmlString stringByAppendingString:@"</span>"];
[webView loadHTMLString:htmlString baseURL:nil];
// [htmlString release]; // <- is this necessary?
}

After the second assignment, htmlString is no longer a literal string, but will be a reference to whatever is returned by - stringByAppendingString:.

That would be an autoreleased string so, no, the -release isn't necessary.

The constant string -- the bits in @" ... " -- should be treated as - autoreleased. That is, technically, you should -retain it if you want it to stick around. However, the reality is that @"..." strings are truly constant in that they are created as a part of compilation/ linking, are never really allocated as they are "just there", can't be deallocated, and don't respond to retain/release/autorelease in the normal way.

But, as Fritz said, treat 'em like regular old autoreleased objects.

b.bum


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to