Proper idom for a failed init?
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.