Objective-c Object Objective-c Object
- Profile
- Creating and Using objects
- News
- In-memory objects
- Id
Profile
Objects: Holds data and contains a set of functions that can use the data that the object holds. Sending a message to an object can trigger the corresponding function. This type of message-triggered function is called a method. (Data-method)
Class: Describes a specific type of object, including methods and instance variables. object to hold the data with an instance variable. An object created from a class, called an instance of that class.
Creating and Using objects
The date method of the NSDate class creates an NSDate instance, initializes it to the current date/time, and then returns the starting address of the new object.
NSDate *now = [NSDate
News
The message send (instruction) must be written in a pair of parentheses, and must contain the following two parts.
nsdate *now = [nsdate Date]; nsdate *later = [now Datebyaddingtimeinterval:100000 ];
Now is the pointer to the object that receives the message, also known as the receiver (the receiver).
Datebyaddingtimeinterval: The method name of the method to be fired, also known as the selector (the selector).
100000 is the passed-in argument.
In-memory objects
The pointer is in the stack, and the value of the object is in the heap.
Id
When you declare a pointer to an object without knowing the exact type of the object you are referring to, you can use the ID type, the meaning of the ID is: pointer , and you can point to any type of ojbective-c object. The ID already implies an asterisk, so you don't need an asterisk to use it.
id delegate;
Objective-c Object