[swift-corelibs-dev] non-inherited init
phausler at apple.com
Thu Mar 17 09:42:01 CDT 2016
That is a comment emitted by the importer, unfortunately it is impossible for non objc to mimic that behavior 100% because it is an init method that is constructed from a class method.
@interface Foo : NSObject
+ (Foo *)fooNamed:(NSString *)name; // this is not an inherited init method in that it will always return an instance of a Foo no matter the subclass it is called from
@interface Bar : Foo
// in objc it is like this:
Foo *f = [Bar fooNamed:@“test”];
// in swift it is like this:
let f = Bar(named:”test”)
but obviously by the method fooNamed always returns a Foo instead of an instancetype because it actually looks up Foo objects from a table.
> On Mar 17, 2016, at 7:35 AM, Daniel Eggert via swift-corelibs-dev <swift-corelibs-dev at swift.org> wrote:
> There're some initializers (namely in NSURLSession) that have a comment:
> public /*not inherited*/ init(...
> What is this “not inherited” comment trying to convey, and how would one go about implementing this in Swift?
> swift-corelibs-dev mailing list
> swift-corelibs-dev at swift.org
More information about the swift-corelibs-dev