• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Class in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Class in Swift


  • Subject: Class in Swift
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Sat, 16 Aug 2014 18:32:53 +0700

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.


_______________________________________________

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


  • Follow-Ups:
    • Re: Class in Swift
      • From: "Stephen J. Butler" <email@hidden>
    • Re: Class in Swift
      • From: Charles Srstka <email@hidden>
  • Prev by Date: Re: How to convert String.Index to UInt?
  • Next by Date: Re: How to convert String.Index to UInt?
  • Previous by thread: Re: Creating pdf document
  • Next by thread: Re: Class in Swift
  • Index(es):
    • Date
    • Thread