0

I've been building and doing all sorts of stuff here using the xcode. It never complained about "leak problems". It has just started since I tried to insert ShareKit.

So.. I removed all traces of ShareKit and 11 entries of "Potential leak of an object" appeared.

Here is one example which is happening with a textView:

file.h

#import <UIKit/UIKit.h>
#import "iAd/iAd.h"
#import "Oracao.h"
#import <QuartzCore/QuartzCore.h>

@interface DetalhesOracaoViewController : UIViewController{
    Cclass *cclass;
}

@property (nonatomic, retain) Cclass *cclass;
@property (nonatomic, retain) IBOutlet UITextView *tWeekDay;

@end

file.m

...
@synthesize tWeekDay;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    self.tWeekDay.text = [NSString stringWithFormat:@"%d° day - %@", cclass.dia, cclass.dia_semana];
}

#pragma mark dealloc
-(void)dealloc {
    [tWeekDay release];
    [super dealloc];
}

Any ideas of what could be done? Thanks!

EDIT:

Here is another leak that I couldn't understand:

Second potential leak

RickON
  • 395
  • 7
  • 18

1 Answers1

0

I think you retain alloced UITextView which first used alloc, than addSubview , than retain. Share code when you create it maybe to be more sure.

So you should balance this

Try :

@property (nonatomic, assign) IBOutlet UITextView *tWeekDay;

or add

-(void)dealloc {
[tWeekDay removeFromSuperview];
[tWeekDay release];
[super dealloc];

}

B.S.
  • 21,660
  • 14
  • 87
  • 109
  • And the object is just placed on XIB and then associated with `@property` and then `@synthesize`. – RickON Mar 26 '13 at 09:56
  • You shouldn't call `[super dealloc]` explicitly, the compiler handles it for you, see this related question http://stackoverflow.com/questions/7292119/custom-dealloc-and-arc-objective-c – lekksi Apr 27 '15 at 13:42
  • You could also try changing the `assign` to `strong` or `weak` in the property declaration, assign should not be used for pointers. @RickOn – lekksi Apr 27 '15 at 13:45
  • Lol I jus noticed this question is over two years old. :D Well, ehm. – lekksi Apr 27 '15 at 13:47