Mar 12, 2012

Use @property

// In the init function
UIView *v = [[UIView alloc] init];
[self addSubview:v];
_someVar = v
[v release];
// In the dealloc function
[_someVar release];
_someVar = nil;
view raw tanin_mistake.m hosted with ❤ by GitHub
Here is what caused the EXC_BAD_ACCESS, and it took me like 2 hours to solve it.

Notice that _someVar is released twice. It's super confusing.

Next time, just use @property.

And, when I want to release it, just set the property to nil.

You cannot really go wrong with @property...