Using the analyzer in XCode 4, I'm getting warnings of potential memory leaks due to setting a property like this:
self.newDog.dogName = self.dogNameTextField.text;
The specific warning is:
Property returns an Objective-C object with a +1 retain count (owning reference).
Object allocated on line 513 is not referenced later in this execution path and has a retain count of +1 (object leaked)
If I don't set the property using self, the warning goes away... but I'm not sure if that won't cause other issues since everything I've read basically says to always use self when setting/getting properties:
newDog.dogName = self.dogNameTextField.text;
Am I doing something else wrong here? Here's some stripped down code from the view controller where the warnings occur:
@interface AddDogViewController : UITableViewController {
Dog *newDog;
}
@property (nonatomic, retain) Dog *newDog;
@implementation AddDogViewController
@synthesize newDog;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// some other code
self.newDog.dogName = self.dogNameTextField.text;
// some other code
}
- (void)dealloc {
[newDog release];
[super dealloc];
}
@end