The syntax specific to the last OC

Source: Internet
Author: User

Note: (because there is no apple around the first summary, the relevant code after the complement) three, description method1.-descriotion Method

When you use NSLog and%@ to output an object, the object's -description method is called and the return value is returned for output .

2.+description Method

When you use NSLog and %@ to output a class object, the Class object +description method is called, and the return value is obtained for output

3. Modify the default output of the NSLog

Rewrite the -description or +description method.

4. Dead Loop traps

If you use NSLog in the -description method, print self .

Iv. SEL1. Where to store the method

The list of methods for each class is stored in the class object

Each method has an object of the corresponding SEL type

The address of the method can be found based on a Sel object, and the method is called

Definition of SEL type

typedef struct OBJC_SELECTOR *sel;

Creation of 2.SEL objects

SEL s = @selector (test);

SEL s2 = nsselectorfromstring (@ "Test")

3.SELother uses of the object

Convert Sel object to NSString Object

NSString *str = Nsstringfromselector (@selector (test));

Person *p = [person new];

Call the test method of the object P

[P Performselector: @selector (test)];

The syntax specific to the last OC

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.