I noticed that Cocoa/Objective-C classes inherit and conform from other classes. I understand what inheritance is, but not conformance. What’s the difference?
Also, is a class like UIView a Cocoa class or an Objective-C class?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Classes don’t conform to classes, they conform to protocols, which are basically lists of messages that a class can respond to. If a class conforms to a protocol, it must respond to all the non-optional messages listed in the protocol interface.
Also, there isn’t really a difference between a Cocoa class and an Objective-C class. Cocoa is an Objective-C framework, so all of its classes are Objective-C classes. If you’re asking whether classes like UIView are part of the language or the framework: Every class you normally interact with in a Cocoa/Cocoa Touch app comes from the framework. The native classes the standard Objective-C runtime provides are:
You can go to /usr/include/objc if you want to see the headers for yourself. None of these are used in a normal Cocoa or Cocoa Touch program. You do use Protocols (as mentioned above), but don’t normally refer to the class directly.