SEL的使用
//SEL的第一種用法:
if 0SEL sel; //1.聲明一個SEL變量sel = @selector(eat); //2.存儲方法名[per performSelector:sel]; //3.執行sel中存儲的方法 endif//SEL的第二種用法:SEL以參數形式出現
[per action:@selector(sleep)]; [per action:@selector(play)];//SEL sel(形參) = @selector(sleep)(實參) //2.SEL存儲方法名 -(void)action:(SEL)sel //1. 聲明SEL { //判斷SEL中的方法是否響應,如果響應,則進入執行 if([self respondsToSelector:sel]) {[self performSelector:sel]; //3.執行sel中的方法 }else{NSLog(@"沒有響應"); } }總結
- 上一篇: 悦诗风吟网络营销的目标_悦诗风吟产品网络
- 下一篇: Python语言的适用范围