zoukankan      html  css  js  c++  java
  • 关于SEL数据类型的简单知识点

    转:http://blog.csdn.net/weisubao/article/details/39964911?utm_source=tuicool&utm_medium=referral

    (1)类里面的方法都是被转换成SEL变量进行存储的。

    (2)类声明一个对象,对象调用方法的时候,系统会被这个方法转换成SEL,然后拿这个SEL到类方法中去匹配。

    (3)我们可以自己手动把方法转换成SEL,然后用这个SEL去查找方法。

     1 #import <Foundation/Foundation.h>  
     2 #import "Person.h"  
     3   
     4 int main(int argc, const charchar * argv[]) {  
     5   
     6     @autoreleasepool {  
     7         Person *p1=[[Person alloc]init];  
     8         //正常方法,需要把eat转换成SEL,然后去匹配查找  
     9         [p1 eat];  
    10         //利用SEL,先我们自己把eat转换成SEL,然后用这个SEL去找  
    11         SEL aaa=@selector(eat);  
    12         [p1 performSelector:aaa];  
    13         //或者合并写成  
    14         [p1 performSelector:@selector(eat)];  
    15     }  
    16     return 0;  
    17 } 
     
  • 相关阅读:
    随机数
    质数
    猜数
    失败
    判断质数
    2019.7.21记录
    9*9乘法表
    小人
    奔跑的字母

  • 原文地址:https://www.cnblogs.com/liuziyu/p/5527190.html
Copyright © 2011-2022 走看看