NSTextField Leaks

Discussion in 'Mac Programming' started by lordsith, Oct 24, 2009.

  1. lordsith macrumors newbie

    Oct 24, 2009
    Hello everybody ... :)

    I Have two NSTextField in my project but when I introduces a word , starting to leaks, I checked in the Instruments -> Leaks

    I Add this code for my ControladorRegistro.h

    @property (nonatomic, retain) IBOutlet NSTextField * correoCampo;
    @property (nonatomic, retain) IBOutlet NSSecureTextField * contrasenaCampo;

    And this one in ControladorRegistro.m

    @synthesize correoCampo;
    @synthesize contrasenaCampo;

    - (void)dealloc
    [super dealloc];


    But the problem still after included that ... I have screenshot


    I hope anyone can help me .. Thanks ... ( Sorry for mi bad english :p )
  2. rossipoo macrumors regular

    Jun 7, 2009
    That code doesn't look like it should compile:
    You're dealloc should be:
    - (void) dealloc {
    	[correoCampo release];
    	[contrasenaCampo release];
    	[super dealloc];
    If something else is the problem, you can use Instruments to discover what method is causing the leaks, by clicking the next button to the right of the blue one selected on the bottom edge of the window, the one with three horizontal lines. A table will come up showing the method stack at the time of the leak. Usually the method nearest the top of the stack, and part of your application, will be responsible for the leak.

    You can also catch many potential leaks (though not this particular one) before you even run by using the Static Analyzer during your compile. You must open your build options, change the compiler to CLang, and check the box next to Run Static Analyzer.
  3. jared_kipe macrumors 68030


    Dec 8, 2003
    You can't send the selector release via the . syntax.

    Also, its good practice to have a method that looks like this in addition to your dealloc releases.

    - (void) viewDidUnload {
    self.correoCamp = nil;
    self.constrasenaCampo = nil;

    In UIViewControllers that have subviews, this uses the @property setter to release the view it currently holds. Remember you can send messages to nil at runtime without generating an exception.
  4. lordsith thread starter macrumors newbie

    Oct 24, 2009

Share This Page