`
473687880
  • 浏览: 478267 次
文章分类
社区版块
存档分类
最新评论

object-c之performSelector学习

 
阅读更多

performSelector用法还是挺多的,一种最简单的用法就是跟直接的实例调用成员函数效果一样:

#import "MySquare.h"

int main(int argc,const char *argv[]){
MyRectangle *rec=[[MySquare alloc]initWithSize:10];

[rec performSelector:@selector(setWidth:) withObject:6];
//[rec setWidth:5];
[rec area];
[rec release];
return 0;
}

就是直接调用了performSelector。

其他的用法之后再看了。

分享到:
评论

相关推荐

    OC-performSelector

    OC-performSelector

    swift performSelector

    swift并没有提供performSelector ,我伪代码写了一个扩展类。使用时请小心。详见我博文说明。http://blog.csdn.net/fengsh998/article/details/35842441

    ios demo,performSelector和respondsToSelector

    ios demo,performSelector和respondsToSelector,动态添加方法,多参数调用

    objective-c小技巧

    [self performSelector:@selector(machineBallAction) withObject:nil afterDelay:0]; 3.实现随机数:srandom(time(NULL)); 4. #pragma mark - #pragma mark Initialization 它们告诉Xcode编译器,要在...

    InvocationDemo

    NSInvocation的作用和performSelector:withObject:的作用是一样的:用于iOS编程中调用某个对象的消息。 performSelector:withObject:调用一些参数较少的消息是比较方便的,但是对于参数个数大于2的消息,使用...

    IOS多线程编程NSThread的使用方法

    IOS多线程编程NSThread的使用...(1)多用于串行:- (id)performSelector:(SEL)aSelector withObject:(id)object; (2)后台执行,多用于并行:- (void)performSelectorInBackground:(SEL)aSelector withObject:(nul

    iOS长按按钮

    [self performSelector:@selector(lazyButtontouchDown) withObject:nil afterDelay:self.minimumPressDuration]; } -(void)lazyButtontouchDown { } //当离开按钮的时候取消所调用的方法 - (void)...

    蓝牙自动开启

    [self performSelector:@selector(toggle:) withObject:btCont afterDelay:1.0f] ; #endif } #if TARGET_IPHONE_SIMULATOR #else - (void)toggle:(id)btCont { BOOL currentState = [btCont enabled] ; [btCont ...

    ftp客户端 ios的库

    [(NSObject*)self performSelector:@selector(request:didUpdateStatus:) withObject:self withObject:status]; 应该是 [(NSObject*)self.delegate performSelector:@selector(request:didUpdateStatus:) with...

    objective c 消息 objc_msgSend

    objective c 消息 objc_msgSend 及 performSelector 的使用例子。

    对比分析iOS延迟执行的4种方式

    代码如下:[self performSelector:@selector(delayMethod) withObject:nil afterDelay:1.0f]; 1.特点: 此方式要求必须在主线程中执行,否则无效。 是一种非阻塞的执行方式, 暂时未找到取消执行的方法。 二、定时器:...

    leetcode题库-iOS-Interview-Questions:收集整理iOS笔试面试题

    performSelector:withObject:方法的作用是什么? 解释一下多态 如何实现深拷贝 http和socket通信的区别,tcp和udp的区别,session和cookie的区别 block实现原理 响应链 frame 和 bounds 写一个宏MIN,这个宏输入两个...

    ios-超简单一个方法实现播放动画.zip

    - (void)playAnimateWithName:(NSString *)name framesNumber:(int)frames {... [self.imageView performSelector:@selector(setAnimationImages:) withObject:nil afterDelay:self.imageView.animationDuration]; }

    iOS中延时执行的几种方式比较及汇总

    前言 在开发过程中,我们有时会希望把一些操作封装起来延迟一段时间后再执行。... [self performSelector:@selector(delayDo:) withObject:nil afterDelay:1.0f];  //带参数 [self performSelector:@selector(delayD

    ios开发小技巧

    [self performSelector:@selector(selectPic:) withObject:imageafterDelay:0.1]; } -(void)selectPic:(UIImage*)image { NSLog(@"image%@",image); imageView = [[UIImageView alloc] initWithImage:image]; ...

    iOS中NSInvocation的基本用法教程

    大家应该都有所了解,在 iOS中可以直接调用某个对象的消息方式有两种:一种是performSelector:withObject;再一种就是NSInvocation。 第一种方式比较简单,能完成简单的调用。但是对于>2个的参数或者有返回值的处理...

    iOS延迟执行方法详解

    近日学习了延迟执行的几种方法,分享一下。 1.performSelector(NSObject)方法  2.NSTimer方法  3.GCD方法  4.sleep(NSThread)方法 延迟执行代码: - (void)delayDo : (id)sender { NSLog(@do:%@,sender); } 1....

    IOS开发中延迟执行和取消

    在 Objective-C 中延迟执行还是很常见的需求,通常有如下几种方式可供选择: performSelector: 想要延迟调用某个方法: [self performSelector:@selector(delay) withObject:nil afterDelay:3.0]; 取消延迟的方法...

    ZFYLoadView:一个加载等待的view,支持自定义动画图片,支持空数据,支持加载失败重新加载

    数据加载完成后消失[self performSelector:@selector(dis) withObject:self afterDelay:4]; //4秒后消失,也就是数据加载完成后执行-(void)dis{ [ZFYLoading dismiss]; }###没有数据 没有数据1 [ZFYLoading ...

    EasyTimeline, 时间轴需要的简单时间线类.zip

    EasyTimeline, 时间轴需要的简单时间线类 EasyTimeline有时你需要在特定的时间和...当它只是一个事件 2.0秒后, performSelector:withObject:afterDelay: 完美。如果需要一些更复杂的事情,那么需要在 3.0秒内进行一

Global site tag (gtag.js) - Google Analytics