Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Class an object, or is it a struct?

Tags:

objective-c

Is Class an object, or is it a struct?

like image 874
dontWatchMyProfile Avatar asked Dec 18 '22 00:12

dontWatchMyProfile


1 Answers

Objective-C classes are considered as objects, with a few restrictions (see Objective-C Programming Language):

Class objects are thus full-fledged objects that can be dynamically typed, receive messages, and inherit methods from other classes. They’re special only in that they’re created by the compiler, lack data structures (instance variables) of their own other than those built from the class definition, and are the agents for producing instances at runtime.

Behind the scene, a class definition contains various kinds of information, much of it about instances of the class:

  • The name of the class and its superclass
  • A template describing a set of instance variables
  • The declarations of method names and their return and argument types
  • The method implementations
like image 108
Laurent Etiemble Avatar answered Dec 28 '22 07:12

Laurent Etiemble