Re: Class in Swift
Re: Class in Swift
- Subject: Re: Class in Swift
- From: Charles Srstka <email@hidden>
- Date: Sat, 16 Aug 2014 15:53:09 -0500
On Aug 16, 2014, at 6:32 AM, Gerriet M. Denkmann <email@hidden> wrote:
> How to translate into Swift:
>
> - (void)myFunctionWithClass: (Class)someClass
> {
> for(...)
> {
> p = ...
> if ( p is not special ) continue;
>
> id <MyProtocol> aClass = [[ someClass alloc] initWithParameter: p ];
> ... do something with aClass ...
> }
> }
>
> Assuming that someClass is costly to initialize and myFunctionWithClass does so only under certain circumstances.
> Or that myFunctionWithClass creates many instances of someClass.
>
> Assuming also, that there is an unlimited number of classes (all implementing MyProtocol).
>
> Which means that there is no way that the caller of myFunctionWithClass could create a someClass and pass it to the method.
>
> How to do this in Swift?
>
> Gerriet.
You can't. Swift does not have as many dynamic features as Objective-C.
Charles
_______________________________________________
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
References: | |
| >Class in Swift (From: "Gerriet M. Denkmann" <email@hidden>) |