[swift-evolution] Better Self support with class funcs

James Campbell james at supmenow.com
Tue Dec 15 09:19:37 CST 2015


When doing this with a UIViewController's init nibname method, I get this
error:

Constructing and object of class type 'Self' with a metatype value must use
a 'required' initialiser.

On Tue, Dec 15, 2015 at 3:11 PM, Stephen Celis <stephen.celis at gmail.com>
wrote:

> You can use `self` (and, to initialize, `self.init`) inside a class
> function to refer to the class. A riff on your example here:
> http://swiftstub.com/914697984/
>
> Stephen
>
> On Tue, Dec 15, 2015 at 6:56 AM, James Campbell via swift-evolution <
> swift-evolution at swift.org> wrote:
>
>> Would be great to construct the current class in a class function like so
>>
>> class func makeMeCheese() -> Self
>> {
>>  return Self(type: .Cheddar);
>> }
>>
>> --
>>  Wizard
>> james at supmenow.com
>> +44 7523 279 698
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>
>>
>


-- 
 Wizard
james at supmenow.com
+44 7523 279 698
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151215/091aa74d/attachment.html>


More information about the swift-evolution mailing list