initialization - Swift: Why class method has return type AnyObject? -
nsdate.distantfuture() documented homecoming object of type nsdate.
so then, why have homecoming type of anyobject, instead of nsdate?
in objective-c distantfuture returns id, not nsdate. automatic swift conversion makes anyobject. when class reviewed apple switch nsdate.
nsdate's distantfuture distant past (at to the lowest degree mac os x 10.0, before that). @ time many mill methods returned id because there no instancetype. create easier phone call subclasses method on returned object.
swift initialization nsdate return-type class-method
No comments:
Post a Comment