IOS Reflex Action

Source: Internet
Author: User

1. Determine whether an object is of a certain type: (The parent class will also return Yes)
class ]


2. Determine whether an object is an instantiated object of a class (the parent class does not return YES)

class ]


3. Determine if an agreement has been implemented

Conformstoprotocol: @protocol (nscopying)

4. Determine if there is a method (can respond to this method)

Respondstoselector: @selector (showmessage:)

Dynamically generate a class

5. Generate a class from a class name

nsstring *[email protected] "Person" ; Class myclass=nsclassfromstring (className)

You can initialize a person object with MyClass

Person *person2=[[myclass Alloc]init]

6. Convert Type to String

class ]

7. Call the method based on the method name string

nsstring *[email protected] "ShowMessage:"//Method name string
SEL myselector=nsselectorfromstring (methodName);  To create a Sel object from a method name string
Performselector:myselector withobject:@"hello,world!"//Execute Method 8. Convert method to String
Nsstringfromselector (Myselector)

IOS Reflex Action

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.