I have an NSThread
that runs the following code:
for (Experiment *exp in experiments) {
ExperimentBlock *block = [[ExperimentBlock alloc] initWithFrame:CGRectMake(0, maxHeight, 310, 50)
experiment:exp
target:self
action:@selector(onExperimentButtonClicked:)];
[scrollView addSubview:block];
// block cannot be released for some inadequately explained reason
maxHeight += 60;
}
Good memory management practice expects us to release any objects we have allocated, copied or new'ed. However, when my thread finishes, if I have released (or autoreleased) the blocks I've added to my UIScrollView
, the objects are displayed in my UIScrollView
for a second before disappearing.
How should I release the memory without losing these objects?