Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getter method for property crashes with EXC_BAD_ACCESS

I've declared a property someProperty and synthesized it:

@synthesize someProperty = _someProperty;

But when I call it in code, I get EXC_BAD_ACCESS in my getter overide method. Why??

- (NSString *) someProperty {  <---EXC_BAD_ACCESS HERE
    if(!self.someProperty)
        return self.someOtherProperty;
    return self.someProperty;
}
like image 353
user1337645 Avatar asked Jun 14 '12 14:06

user1337645


1 Answers

I think you might be getting a Stack Overflow! because the line

if(!self.someProperty)

will be calling

- (NSString *) someProperty

recursively until the recursion stack overflows.

Similarly if it could get to the return line, it would do the same thing.

like image 73
James Webster Avatar answered Nov 14 '22 22:11

James Webster