Re: bundleForClass in Swift
Re: bundleForClass in Swift
- Subject: Re: bundleForClass in Swift
- From: Graham Cox <email@hidden>
- Date: Sun, 19 Oct 2014 14:47:45 +1100
On 19 Oct 2014, at 2:43 pm, Rick Mann <email@hidden> wrote:
> Sorry, I was conflating Obj-C and Swift syntax. I'm trying to do this all in swift, in which case it's:
>
> NSBundle(forClass: self.dynamicType)
>
> But you can't call this in an initializer before calling super init.
>
Well, I'm not working in Swift so it may not have parity with Obj-C in some ways that I haven't understood, but isn't there a way to just name the class, rather than asking self what it is?
Also, there's no rule about executing code before calling super init, as long as it does not rely on the state of the object being inited. You can certainly call into NSBundle at that time, just not using [self class] (or its Swift equivalent) but [MyClass class] (or its Swift equivalent).
--Graham
_______________________________________________
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