• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Exiting cleanly the init method under ARC
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Exiting cleanly the init method under ARC


  • Subject: Exiting cleanly the init method under ARC
  • From: Tito Ciuro <email@hidden>
  • Date: Wed, 27 Jun 2012 09:12:53 -0700

Hello,

Under non-ARC, an init method may be implemented like this:

- (id)init
{
    self = [super init];

    if (self) {
        if (<somecondition != good>) {
            [self release];
            return nil;
        }

        // Initialize ivars here as usual...
    }

    return self;
}

However, if something critical happens within the init method when ARC is activated, what would be the proper way to exit? Would it look like this?:

- (id)init
{
    self = [super init];

    if (self) {
        if (<somecondition != good>) {
            // Cleanup here if needed...
            return nil;
        }
    }

    return self;
}

Thanks,

-- Tito


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Exiting cleanly the init method under ARC
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Moving from popup to text field cell in table view core data binding causes exception
  • Next by Date: Re: Exiting cleanly the init method under ARC
  • Previous by thread: Re: Moving from popup to text field cell in table view core data binding causes exception
  • Next by thread: Re: Exiting cleanly the init method under ARC
  • Index(es):
    • Date
    • Thread