问题
I am a newbie, and I am wondering what an instance of NSObject is. I am working on Xcode 3.2 and want to know what the instance is. I've heard this term often and am confused by it.
回答1:
From Wikipedia on Objects in OOP
Objects in "object-oriented programming" basically are data structures combined with the associated processing routines. For instance, a file is an object: a collection of data and the associated read and write routines. Objects are considered instantiations of classes. In common parlance one refers to a file as a class, while the file is the object. A class defines properties an behaviour once, usually for multiple instantiations. In other disciplies, this distincion is also known as gen genus/species dichotomy.
...
In a language where each object is created from a class, an object is called an instance of that class. If each object has a type, two objects with the same class would have the same data type. Creating an instance of a class is sometimes referred to as instantiating the class.
Essentially the NSObject is the base object type in Apple development. The NSObject defines all things that are shared between all classes
that extend from it:
NSObject is the root class of most Objective-C class hierarchies. Through NSObject, objects inherit a basic interface to the runtime system and the ability to behave as Objective-C objects.
I would recommend taking some time to learn the basics of programming and OOP style programming if you are struggling with the definition of object instantiation. Understanding this concept is paramount to success down the road, and if you continue without learning the basics you will create further frustration.
来源:https://stackoverflow.com/questions/10438986/what-is-an-instance-of-an-nsobject