Objective-c Object

Source: Internet
Author: User

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.

    • Pointer to the object to receive the message

    • Method Name, method name to trigger the method

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.