site_archiver@lists.apple.com Delivered-To: cocoa-dev@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=fm1; bh=NrawCi0/GZ6xl2l471 JT4yAUktxJkdcmBF0s3VRiqd4=; b=bAESL5XkIDc4nWZUpKEUgfMkdf6EnCTLZL IWP4RQ6IPHf5iAmeG5A03Tq1hcGj4Iha6IlDv7NtOUJnsRjTZr2uDrOyD2cO89uW sY0B6gMU/DRpV/gBa2oh4I3v0g83MPqCF6dA4iDfbAr5XXZtRYWqwdd1bshinOZ7 cEieir6nYhpNYjBnpC72Kvk704SFqTNkTlcQhBUK5/USy5e0wakZXSvPZCRdowbW mqLtEmPxI+mfIP4Y9gaCrgiLM7FbYFqskqcQOBJ+rlhsNILEnjF0cxUKbRUAVeIJ HaF7mB+riAQVkMDeoz9Fpr31j0lFFEkoYtMWdwShUh3l8mP/hA+Q==
On Aug 7, 2017, at 5:02 PM, David Hoerl <dhoerl@mac.com> wrote:
But then I though - heck, if Foo has NSObject as its super class, gee, maybe -init isn't really need. I mean, if all of Foo's ivars and properties are initialized, its a shortcut, right.
-[NSObject init] happens to be a no-op empty method. So if a direct subclass of NSObject has no -init method of its own, you could get by with just calling +alloc. However, I think this would be a really bad idea. If at some point you needed to add an -init method to class Foo, like to initialize an ivar, you’d have to go and fix all this code that wasn’t calling -init, or else you’d suddenly have a number of bugs in your code. Even worse, if someone else added the -init method and didn’t know about this quirk of how callers initialized Foo, they might have no idea why their method didn’t get called. Yuck. —Jens _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
Jens Alfke