Re: bundleForClass in Swift
Re: bundleForClass in Swift
- Subject: Re: bundleForClass in Swift
- From: Rick Mann <email@hidden>
- Date: Sat, 18 Oct 2014 20:54:48 -0700
> On Oct 18, 2014, at 20:47 , Graham Cox <email@hidden> wrote:
>
>
> 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).
You're probably right about that, but in this case, you wouldn't be able to pass self for owner:
--
Rick Mann
email@hidden
_______________________________________________
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