• 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
Re: don't understand -[MyDocument init]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: don't understand -[MyDocument init]


  • Subject: Re: don't understand -[MyDocument init]
  • From: Jérôme Laurens <email@hidden>
  • Date: Mon, 4 Nov 2002 12:08:13 +0100

Le jeudi, 31 oct 2002, ` 16:34 Europe/Zurich, David Remahl a icrit :

> Nope, you didn't miss anything. But both methods work. Check the
> archives
> from several months ago for a discussion on this issue.
>
> / Regards, David

Sorry, but this does not help if both methods work now, nothing tells
us that they will ever work, moreover, the following code seems to show
that not using self = [super init] is a mistake:

#import <Foundation/Foundation.h>

@interface MyObject: NSObject
@end
@interface MySubObject: MyObject
@end

int main (int argc, const char * argv[]) {
[[[MySubObject alloc] init] release];// release message sent to a
dealloc'ed instance: crash
return 0;
}
@implementation MyObject
- (id) init;
{
[self dealloc];// models a problem in initialization
self = nil;
return self;
}
@end
@implementation MySubObject
- (id) init;
{
[super init];// error: this must be coded self = [super init];
NSLog(@"super has been inited: 0x%x", self);// self has been
dealloc'ed and set to nil in the inherited method but it does not point
to 0...
return self;
}
@end
_______________________________________________
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.

  • Prev by Date: RE: cocoa-dev digest, Vol 2 #1476 - 12 msgs
  • Next by Date: Clearing cells in NSBrowser
  • Previous by thread: RE: cocoa-dev digest, Vol 2 #1476 - 12 msgs
  • Next by thread: Clearing cells in NSBrowser
  • Index(es):
    • Date
    • Thread