Throwing an error from a NSDocument.init override
Throwing an error from a NSDocument.init override
- Subject: Throwing an error from a NSDocument.init override
- From: Daryle Walker <email@hidden>
- Date: Tue, 14 Feb 2017 03:26:40 -0500
The parameter-less version of “init” in NSDocument can’t throw. It’s suggesting to (save the error somehow and then) throw the error from one of the other initializers. This counts on the fact that you won’t initialize a NSDocument (subclass) instance with no parameters, but call one of the others, which calls “init()”.
But I can’t call the “super” versions of those other initializers from within my override. In fact, I can’t create overrides of them; the Swift compiler won’t auto-complete and insists that I mark them as “convenience” initializers. And I am limited to my “self.init()” call to start them up. Do I have to manually recreate the algorithm for each initializer overload(?)? Will NSDocumentController and other parts of the framework see my “overrides” of the standard NSDocument initializers and use them instead? Or should I just forget about throwing errors from “init()”? I could just call “fatalError” or similar instead.
(Oh, I got error objects because I’m initializing my (per-document) Core Data stack in “init()”.)
—
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com
_______________________________________________
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