• 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
verify input parameter of init method and return nil before invoke [super init]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

verify input parameter of init method and return nil before invoke [super init]


  • Subject: verify input parameter of init method and return nil before invoke [super init]
  • From: Bob Cromwell <email@hidden>
  • Date: Tue, 29 Jan 2013 16:51:30 +0800

Hi All,

if below code valid ?   All sample codes I could find invoke "self = [super init]" first and then check the input parameter inside "if (self)" block.

@implementaion Bla

- (id)initWithFoo:(NSString *)foo
{
    if (foo == nil) {
        return nil;
    }
    self = [super init];
    if (self) {
        _foo = foo;
        .....
    }
    return self;
}

I had thought there would be memory leak.   "Bla * b =  [Bla alloc ] initWithFoo:nil];" .  However under ARC using Instruments Leaks, there are no leak found.

Thanks in advance!

Bob Cromwell

_______________________________________________

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: verify input parameter of init method and return nil before invoke [super init]
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: NSNetService
  • Next by Date: Re: verify input parameter of init method and return nil before invoke [super init]
  • Previous by thread: Re: NSNetService
  • Next by thread: Re: verify input parameter of init method and return nil before invoke [super init]
  • Index(es):
    • Date
    • Thread