cliffspencer/ViewTest — pull request #1 by MattFoley (2014-11-11 04:46:31+00:00)
Title: view outlet change

This is the only problem I can find here. This "view" property I think needs to be strong, because otherwise it could be deallocated in between the loadNib call and the addSubview call.

It might be intermittent too because it's possible that the addSubview: method is invoked before it's deallocated, and it's superview will up it's retain count, stopping it from being deallocated.

This is definitely the problem if you're adding and removing "view" at certain points for UI stuff in your app. If you omit the [self addSubview:self.view] line from "sharedInit:" you'll see that it's null and deallocated every time. Use something like this to check.

- (void)didMoveToSuperview
{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSLog(@"Inner View's self.view property %@", self.view);
});
}

Same thing happens if you do "removeFromSuperview" on self.view when self.view is (weak), it'll be deallocated before you get to another "addSubview:". If that's not the problem, then I'm not sure? Try reseting the simulator, deleting derived data, etc. :-/