• 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: Beginner memory management question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Beginner memory management question


  • Subject: Re: Beginner memory management question
  • From: Luke Hiesterman <email@hidden>
  • Date: Wed, 03 Dec 2008 21:27:51 -0800

What you should do is declare newName as a property and then do self.newName = [stockName stringValue];

The synthesized property will take care of retaining and releasing for you.

Luke

Sent from my iPhone.

On Dec 3, 2008, at 2:13 AM, Jacob Rhoden <email@hidden> wrote:

I am not sure how one would go about working this, Im writing my first "test" os/x applications and I am thinking this is probably not right. Am I doing the retain in the correct place? I tried reading the documentation on NSTextField but it didnt give me a clue about if I needed to "retain". (Infact stringValue is not even mentioned in the NSTextField documentation).

@interface StockListController : NSObject {
   IBOutlet NSTextField* stockName;
   NSString *newName;
}
-(IBAction) addStockItem:(id)sender;
@end

@implementation StockListController

-(IBAction) addStockItem:(id)sender {
   if(newName == nil) [newName release];
   newName = [stockName stringValue];
   [newName retain];
}

_______________________________________________

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
_______________________________________________

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


References: 
 >Beginner memory management question (From: Jacob Rhoden <email@hidden>)

  • Prev by Date: Re: Beginner memory management question
  • Next by Date: Re: self = [super init];
  • Previous by thread: Re: Beginner memory management question
  • Next by thread: Re: Beginner memory management question
  • Index(es):
    • Date
    • Thread