View Full Version : NSTextField Leaks

Oct 24, 2009, 09:46 PM
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

SCREENSHOOT (http://img35.imageshack.us/img35/107/problemds.png)

I hope anyone can help me .. Thanks ... ( Sorry for mi bad english :P )

Oct 25, 2009, 12:21 AM
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.

Oct 25, 2009, 12:27 AM
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.

Oct 25, 2009, 07:00 PM
thanks ! ;)