• 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
When does an object own its instance variable?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

When does an object own its instance variable?


  • Subject: When does an object own its instance variable?
  • From: Bob Ueland <email@hidden>
  • Date: Fri, 17 Aug 2007 03:14:29 -0700 (PDT)

I'm reading Kochan's book "Programming in Objective-C". In chapter 15 he has the following piece of code:

interface AddressCard: NSObject
{
  NSString  *name;
...
}
-(void) setName: (NSString *) theName;
...
@end


@implementation AddressCard;
-(void) setName: (NSString *) theName
{
   name = [[NSString alloc] initWithString: theName];
}
...
@end



Explaining the code he says; Defining the method this way:
-(void) setName: (NSString *) theName
{
  name = [NSString stringWithString: theName];
}

would be the incorrect approach because the AddressCard method would not own its name object, NSString would own it. I do not understand it. Could somebody explain what he means?

Thanks Bob




      ____________________________________________________________________________________
Park yourself in front of a world of choices in alternative vehicles. Visit the Yahoo! Auto Green Center.
http://autos.yahoo.com/green_center/
_______________________________________________

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: When does an object own its instance variable?
      • From: Tony Wroblewski <email@hidden>
  • Prev by Date: RE: How to enable menu items for the submenu of NSPopupButton?
  • Next by Date: Re: How to enable menu items for the submenu of NSPopupButton?
  • Previous by thread: Elango C has added you as a friend on YouMint.
  • Next by thread: Re: When does an object own its instance variable?
  • Index(es):
    • Date
    • Thread