Getter method for property failures with EXC_BAD_ACCESS

I declared someProperty property and synthesized it:

@synthesize someProperty = _someProperty;

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

- (NSString *) someProperty {  <---EXC_BAD_ACCESS HERE
    if(!self.someProperty)
        return self.someOtherProperty;
    return self.someProperty;
}
+5
source share
1 answer

I think you can get a stack overflow! because the line

if(!self.someProperty)

will cause

- (NSString *) someProperty

recursively until the recursion stack overflows.

Similarly, if he could fall into the return line, he would do the same.

+9
source

All Articles