Re: Swift circular imports
Re: Swift circular imports
- Subject: Re: Swift circular imports
- From: Alex Kac <email@hidden>
- Date: Tue, 03 Nov 2015 10:25:50 -0700
- X_v_e_cd: 712d3ca5468a1c3f0cd70dbba81a4962
- X_v_r_cd: f19bbd174f64e57dc2e9fde6f84318f1
Well, I guess I’m back to using extensions instead of subclassing:
"However, note that you cannot subclass a Swift class in Objective-C.”
I had assumed that meant a native non-NSObject based Swift class…but I was wrong. So there…learned something new today.
So never mind!
> On Nov 3, 2015, at 10:07 AM, Alex Kac <email@hidden> wrote:
>
> I’ve got a bit of a foggy head this morning so perhaps I’m just not thinking clearly. We are moving our code from Obj-C to swift. All new code is in Swift. We are hitting an issue with a circular import however.
>
> So here is an example:
>
> App Delegate is still in ObjC, but all new code is written in an extension in Swift. The goal is to move more and more code into Swift and eventually turn it around where the app delegate is a Swift class with an objective C extension.
>
> The App Delegate.swift refers to classes that are written in Objective C - our main View Controllers.
> We are writing a new super class for our main view controllers in Swift, but the view controllers themselves are still ObjC (for now).
>
> So you have a Swift extension, calling an objective C subclass of a swift super class.
>
> Hopefully you see the problem: Swift has to compile first to generate its -Swift.h file, but it can’t compile since the header for the main view controllers refer to a Swift super class (so no forward declarations), and the main view controller headers don’t work until the -Swift file is generated.
>
> So I’m curious if anyone else has had to hit that scenario and what was your solution (besides rewriting everything into Swift…which is kind of what I’ve been doing, but now I’ve hit large classes I’m not into that yet).
>
>
> Also, how do I change my email address for this list without unsubscribing/resubscribing - or is that the only way?
>
>
Alex Kac - El capitán
_______________________________________________
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