> On Jun 6, 2015, at 2:43 AM, Roland King <[email protected]> wrote:
> 
> 
> 
> public class RDKBLEService : NSObject
> {
>       let peripheral : CBPeripheral
> 
>       public init( peripheral: CBPeripheral )
>       {
>               self.peripheral = peripheral
>       }
> }
> 
> It’s a designated initialiser, there’s a superclass (NSObject) but the 
> initialiser doesn’t call a designated initialiser of the superclass. 
> According to the rules I was just re-re-re-reading about Swift 
> initialisation, it’s required to call a superclass designated initialiser 
> from your derived class. I was looking to see if I could find an exception to 
> the rule which this fell under but can’t. 

There is an exception in the designated initializer rule: if your superclass is 
NSObject then you may omit the call to -[NSObject init]. The compiler knows 
that -[NSObject init] does nothing, so it allows this as a performance 
optimization.

NSObject Class Reference:
    "The init method defined in the NSObject class does no initialization; it 
simply returns self."
There is lots of existing code that would break if we changed that, so we can't 
even if we wanted to.


-- 
Greg Parker     [email protected]     Runtime Wrangler



_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to