Please note, I am not using Interface Builder.
I have made my subViews __weak so that they are automatically zero'd on iOS 5 with ARC when they the objects they reference are deallocated. This means I don't have to zero them manually in viewDidUnload (which seems the safest pattern to adopt).
However because they are weak I cannot directly assign them to my ivars when I alloc them, or ARC immediately releases them, the only solution I have found is assigning to a temporary strong local variable like so:
UIView *strongTmp = [[UIView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:strongTmp];
weakIVar = strongtmp;
This is ugly and its purpose is not immediately obvious without a verbose comment. I want something (more) elegant like:
[self.view addSubview:weakIVar = [[UIView alloc] initWithFrame:self.view.bounds]];
But this generates the same compiler warning (the object will be released immediately after assignment).
Any suggestions? Thanks in advance.