0
votes

i created one NSString fName property with retain attribute,and synthesised that property . i initialised that property on viewDidLoad.

my actual prob is , i used [self.fName release]. this sample working fine , but static analyzer showing this line as error 'Incorrect decrement of the reference count of an object that is not owned at this point by the caller'.

reference Code:

@interface ViewController : UIViewController

@property(nonatomic,retain)NSString *fName;

@end

@implementation ViewController
@synthesize fName;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.fName =@"Hello";

    [self.fName release];//Analyzer showgin error here.

}
---------
------
end
1

1 Answers

0
votes

There is no need for release there. You don't alloc/init anything. If you are doing something like this:

self.fName = [[NSString alloc] initWithString:@"Hello"]; 

then you have to release the self.fName.

As a rule of thumb numberOfReleases = numberOfAlloc.

And now, the golden rule, USE ARC :)