• 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
Proper idom for a failed init?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Proper idom for a failed init?


  • Subject: Proper idom for a failed init?
  • From: Dave Fayram <email@hidden>
  • Date: Sat, 7 Sep 2002 17:54:41 -0700

Hi.
I've got several books on cocoa and I've been shuffling through various bits of code trying to
learn it, but I can't find any info on this. What happens if the init of your object fails? Maybe because
of invalid parameters or maybe your object (like mine) interfaces with a device that may not be
read when the object is instantiated. It should fail, and I'd like to avoid memory leaks if at all
possible. Since the memory is already alloc'd, do I need to dealloc it?

In code:

- initWithSomeCriticalJunk:(NSString *)junk
{
if( self = [super init] ) {
if( [junk isValid] ) {
// Keep initalizing
// ...
}
else {
// This should fail, what do I put here?
}
}

Thanks.

- Dave Fayram
Freelance Coder / UCSB Student / Idealist
"Not everyone finds Drag'N'Drop as intuitive as they should."
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Proper idom for a failed init?
      • From: Ondra Cada <email@hidden>
  • Prev by Date: Re: NEWBIE: NSArray toll-free-bridged with CFArray?
  • Next by Date: OT: fun with phonics...
  • Previous by thread: Re: OT: fun with phonics...
  • Next by thread: Re: Proper idom for a failed init?
  • Index(es):
    • Date
    • Thread