objective c - Why send a class through +(Class)class before calling a class method? -
i've been browsing sketch, example program ship xcode, , keep seeing things (not though):
[[myclass class] classmethod]
now, since myclass
isn't instance of class, do:
[myclass classmethod]
as experiment though, able make difference between 2 above statements, overriding + (class)class
, returning another class! if ever want this, need former version work, can see there could usage this, there really?
it sounds awful idea tampering +class
, please enlighten me if there is. thanks!
to see examples, check out method -copy:
in sktgraphicsview.m
in sketch program found in developer/examples/sketch/
.
in case cited, don't see reason calling +class
. however, there definitely case calling [[self class] dosomething]
instead of [[myclass class] dosomething]
. in first case, [self class]
can return correct result if object has been subclassed. in second case, myclass
class object, means mysubclass
not override +dosomething
class method.
Comments
Post a Comment