• 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: Memory allocation issues with NSObject and NSString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Memory allocation issues with NSObject and NSString


  • Subject: Re: Memory allocation issues with NSObject and NSString
  • From: Bill Bumgarner <email@hidden>
  • Date: Sun, 18 Jan 2009 20:21:11 -0800

On Jan 18, 2009, at 8:09 PM, Devraj Mukherjee wrote:
1. If I have an NSString and I simply assign it = @"" does that
initialize it or do I have do go NSString *someString = [[NSString
alloc] init];

foo = @""; // foo is a reference to the empty string foo = [[NSString alloc] init]; // foo is a reference to the empty string

The second is retained. The first is not. The first is a constant string and, thus, -retain/-release is a no-op. An implementation detail to ignore:

foo = [@"" retain];

2. If I have an NSObject class and I define an init messge, do I have
to do self = [super init] or is that not important when extending from
NSObject.

Yes, it is important.

But it does next to nothing.

For now.  Someday, that might change.

b.bum

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Memory allocation issues with NSObject and NSString
      • From: Michael Ash <email@hidden>
    • Re: Memory allocation issues with NSObject and NSString
      • From: Chris Suter <email@hidden>
References: 
 >Memory allocation issues with NSObject and NSString (From: "Devraj Mukherjee" <email@hidden>)

  • Prev by Date: Memory allocation issues with NSObject and NSString
  • Next by Date: Re: ObjC in time-critical parts of the code
  • Previous by thread: Memory allocation issues with NSObject and NSString
  • Next by thread: Re: Memory allocation issues with NSObject and NSString
  • Index(es):
    • Date
    • Thread