small medium large xlarge

Back to: All Forums  iOS Recipes
11 Mar 2012, 09:21
Bernd Rabe (23 posts)

Hi Matt, Paul,

great work thx. Inspired me in many ways.

Especially the self-contained PRPAlertview.

Tried to do the same with one of my classes and failed - somehow :(

I followed you pattern as follows

+ (void)createAutoreleaseObjectWithArguments:(UIViewController *)callingViewController
   cleanupBlock:(SelfContainedClass_cleanupBlock)cleanupBlk {

 [[[[self alloc] initAutoreleaseObjectWithArguments:object initBlock:initBlk completionBlock:completionBlk cleanUpBlock:cleanUpBlk] autorelease] present];

The base class is UIViewController which initialized via

if ((self = [super initWithNibName:NSStringFromClass([self class]) bundle:nil])) {
 init class specific variables
return self;

within the initAutoreleasedObjectWithArguments method.

The callingViewController is retained, the blocks copied. The present method adds the view to the callingViewControllers view.

When I call

[SelfContainedViewControllerClass createAutoreleasedObjectWithArguments ...];

the class is created the user interface presented but the class is immediatly released. If I ommit the autorelease call it is never released.

The only difference to PRPAlertView is the delegate which I haven’t.

Can you see an obvious problem with this construction?


SOLVED Had to keep a reference that was clear but I didn’t know how .. but rtfm (read the … manual) helped me. I simply added my controller as childViewController and during cleanup removeFromParentViewController.

  You must be logged in to comment