Common methods of ios-oc-Foundation-nsobject

Source: Internet
Author: User

1Person *person1 =[[Person alloc]init];2Person *person2 =[[Person alloc]init];3     4 //private methods in the class can be called, but there is a warning5 [Person1 performselector: @selector (Actiontow)];6[Person1 performselector: @selector (actionone:) Withobject:@"Test"];7     8NSLog (@"address of Person1:%p", Person1);9NSLog (@"address of Person2:%p", Person2);Ten      One //compares two objects for the same address A     if([Person1 Isequal:person2]) { -NSLog (@"Two object addresses are the same"); -}Else{ theNSLog (@"Two object addresses are different"); -     } -      - //determine whether an object belongs to a class or to his parent class +     if([Person1 Iskindofclass:[personclass]]){ -NSLog (@"Person1 belongs to the person class"); +     } A      at     if([Person1 Iskindofclass:[nsobjectclass]]) { -NSLog (@"Person1 belongs to NSObject class"); -     } -      -      - //Determines whether an object belongs to a class, but cannot determine its parent class in     if([Person1 Ismemberofclass:[personclass]]){ -NSLog (@"Person1 belongs to the person class"); to}Else{ +NSLog (@"The genus Person1 is not of the person category"); -     } the      *     if([Person1 Ismemberofclass:[nsobjectclass]]) { $NSLog (@"Person1 belongs to NSObject class");Panax Notoginseng}Else{ -NSLog (@"The genus Person1 is not of the NSObject class"); the     } +      A //determines whether a method is implemented in. m the     if([Person1 respondstoselector: @selector (Actiontow)]) { +NSLog (@"Person1 implements the Actiontow"); -}Else{ $NSLog (@"Person1 did not implement the Actiontow"); $}

This article GitHub address Https://github.com/zhangkiwi/iOS_SN_NSObject

ios-oc-Basic-nsobject Common methods

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.