On Tue, Sep 15, 2015, at 01:23 PM, Jens Alfke wrote: > > > On Sep 15, 2015, at 10:52 AM, Kyle Sluder <k...@ksluder.com> wrote: > > > > Class<ProtocolX> really is a Class (instance of metaclass). > > That seems to be true, based on a bit of testing I just did. But I don’t > think a type like that makes sense, since it says that the metaclass > implements the protocol, which isn’t true; the metaclass would have to > implement the “meta-protocol”, and I don’t know if such an entity exists > explicitly in Obj-C. (I can’t rely on analogy to Smalltalk-80 because > Smalltalk didn’t have protocols.) > > For example, if a Class implemented NSCoding that would imply the > metaclass had methods like encodeWithCoder:, which isn’t true.
Recall that class methods are simply instance methods on the metaclass. So Class<SomeProto> makes a statement about what messages you can send to the class: the ones that are prefixed with a + in the protocol definition. So while Class<NSCoding> isn't a useful type because NSCoding doesn't define any class methods, Class<NSSecureCoding> is useful because it tells you that the class object responds to @selector(supportsSecureCoding). > > > Check out UIAppearance.h; that's how containment-based appearance works. > > Hm, I don’t see anything related to metaclasses there, just protocols > with class methods. See the type for the argument to +appearanceWhenContainedIn:. It's a Class<UIAppearanceContainer>. Not an explicit mention of metaclasses, but at least proof that we use the Class<SomeProto> syntax to refer to classes, not instances. --Kyle Sluder _______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (Xcode-users@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/xcode-users/archive%40mail-archive.com This email sent to arch...@mail-archive.com