博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
更加灵活的“ performSelector
阅读量:4614 次
发布时间:2019-06-09

本文共 1399 字,大约阅读时间需要 4 分钟。

I want to invoke a selector of a method that has the usual NSError** argument:

-(int) getItemsSince:(NSDate *)when dataSelector:(SEL)getDataSelector error:(NSError**)outError  {
    NSArray *data = nil;     if([service respondsToSelector:getDataSelector]) {
        data = [service performSelector:getDataSelector withObject:whenwithObject:outError];         // etc.
 

... which the compiler doesn't like:

warning: passing argument 3 of 'performSelector:withObject:withObject:' fromincompatible pointer type

¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
签出 ,这使您可以更灵活的方式的"performSelector"。
if ([service respondsToSelector:getDataSelector]) {
    NSArray *data;     NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:         [service methodSignatureForSelector:getDataSelector]];     [invocation setTarget:delegate];     [invocation setSelector:getDataSelector];     // Note: Indexes 0 and 1 correspond to the implicit arguments self and _cmd,      // which are set using setTarget and setSelector.     [invocation setArgument:when atIndex:2];      [invocation setArgument:outError atIndex:3];     [invocation invoke];     [invocation getReturnValue:&data]; }
 
perform selector调用超过两个以上参数的方法
也可以把所有的参数放到字典里, 像NSNotification或者NSTimer的userinfo

转载于:https://www.cnblogs.com/APTX4869/archive/2011/08/08/2130639.html

你可能感兴趣的文章
yii2 rules 验证规则
查看>>
去掉bootstrap表单空间获得焦点时四周的闪光阴影
查看>>
不能下载源码idea maven
查看>>
矩阵乘法快速幂 cojs 1717. 数学序列
查看>>
设计模式理解(八)结构型——装饰者模式(记得加上UML图 --- 未完)
查看>>
iframe实现局部更新
查看>>
java 1.5 自动拆箱和装箱的注意事项
查看>>
python3 smtp 自动发送邮件
查看>>
七分频占空比为50%电路设计
查看>>
使用ASP.NET AJAX ,遇到Sys 未定义解决方法
查看>>
jenkins 每个月1号到7号 一天执行一次
查看>>
HTML页面生成ASPX页面
查看>>
Linux程序设计(第4版)
查看>>
PHP中的11个魔术方法总结:__construct,、__destruct、__call等
查看>>
Python3学习笔记十三
查看>>
垃圾回收的常见算法
查看>>
什么是obj文件?
查看>>
linux中 tar .gz bz2 xz 怎么用 解压
查看>>
旧题再做【bzoj2287】【[pojchallenge]消失之物】分治背包
查看>>
开源视频服务软件MJPG-streamer移植
查看>>