1.NSInvocation存储

-(void)setInvok:(id)target sel:(SEL)sel key:(id)key
{
if(!target) return;
NSMethodSignature *sig=[target methodSignatureForSelector:sel];
NSInvocation *invo=[NSInvocation invocationWithMethodSignature:sig];
[invo setTarget:target];
[invo setSelector:sel]; NSDictionary *dict = [self currentStyleDict];
[dict setValue:invo forKey:key];//以key的形式保存invo
} -(NSInvocation*)selectInvok:(NSString *)key style:(PALiveStyle)style
{
NSDictionary *dict = [self getStyleDict:style];
return [dict valueForKey:key];
}

http://blog.sina.com.cn/s/blog_4beb28f30100qask.html

2.函数指针

//常规写法
switch ( oper ){
case ADD:
result = add( oper1, oper2 );
break;
case SUB:
result = sub( oper1, oper2 );
break;
case MUL:
result = mul( oper1, oper2 );
break;
case DIV:
result = div( oper1, oper2 );
break;
...
}
//使用转移表之后的写法
double add( double, double );
double sub( double, double );
double mul( double, double );
double div( double, double );
...
double (*oper_func[])( double, double ) = {
add, sub, mul, div, ...
};
//下面的语句替换前面整条switch语句
result = oper_func[ oper ]( op1, op2 );

https://segmentfault.com/a/1190000000578532

3.runtime

http://justsee.iteye.com/blog/2163777

4.调用是arg后记得传nil

- (bool)startPlayingStream:(NSString *)streamID inView:(UIView*)view
{
// NSInvocation *invo=[[MessageInvok shareInvok] selectInvok:@"start_playing_stream" style:PALiveStyleNormal];
// if(invo)
// {
//// [data retain];
// [invo setArgument:&streamID atIndex:2]; //设置参数
// [invo setArgument:&view atIndex:3]; //设置参数
// [invo invoke]; //调用
// }
// [self invokeMethod:@"start_playing_stream" style:PALiveStyleNormal,streamID,view];
[self invokeMethod:@"start_playing_stream" style:PALiveStyleNormal arg:streamID,view, nil]; return true;
} - (bool)stopPlayingStream:(NSString *)streamID
{ return true;
} -(NSInvocation *)invokeMethod:(NSString *)method style:(PALiveStyle)style arg:(id)arg, ...
{
NSMutableArray *arrayList = [NSMutableArray array]; id eachItem;
va_list argumentList;
if (arg)
{
[arrayList addObject: arg];
va_start(argumentList, arg);
while((eachItem = va_arg(argumentList, id)))
{
[arrayList addObject: eachItem];
}
va_end(argumentList);
} NSInvocation *invo=[[MessageInvok shareInvok] selectInvok:@"start_playing_stream" style:style];
if(invo)
{
for (NSUInteger i =; i<arrayList.count; i++) {
NSInteger idx = i+;
id data = arrayList[i];
[invo setArgument:&data atIndex:idx];
} [invo invoke]; //调用
} return invo;
}

5.lldb e

e aView.backgroundColor = [UIColor greenColor];

http://yulingtianxia.com/blog/2015/11/13/Summary-of-the-first-month-in-the-internship-of-Tencent/

https://github.com/opensource-apple/objc4/blob/master/runtime/Messengers.subproj/objc-msg-x86_64.s

最新文章

  1. C++-Qt【5】-QT的QString,char*,QByteArray转化以及中文乱码的问题
  2. 十大Intellij IDEA快捷键(转)
  3. spi接口的ds1302时钟芯片控制在lcd1602上显示
  4. CookieStore之Cookie的获取与保存
  5. 【leetcode】Regular Expression Matching
  6. MySQL中的备份和恢复
  7. linux中如何查看进程对应的cpu使用情况?
  8. BroadcastReceiver的最简单用法
  9. 为什么iphone手机比android手机流畅
  10. JDBC小结
  11. Eclipse + CDT + YAGARTO + J-Link,STM32开源开发环境搭建与调试
  12. 使用wininet向FTP服务器发送文件
  13. Qt多线程(有详细例子)
  14. 笔记:Hibernate 持久化类标注示例-双向1-N关系映射
  15. 敏捷冲刺每日报告二(Java-Team)
  16. boostrap日期时间插件datetimepicker使用过程的一些问题总结
  17. [Swift]LeetCode257. 二叉树的所有路径 | Binary Tree Paths
  18. 自动的输入号码的辅助软件在ie浏览器下的尝试
  19. pygame 笔记-6 碰撞检测
  20. 使用Chrome开发者工具调试Android端内网页(微信,QQ,UC,App内嵌页等)

热门文章

  1. Linux文件权限属性后面有个点
  2. codeforces431B
  3. BZOJ2124 等差子序列(树状数组+哈希)
  4. 【阿里云】云服务器 ECS部署网站
  5. Spring bean默认为单例模式会引发并发问题吗
  6. 完全卸载迈克菲Mcafee的工具
  7. SimpleDateFormat是线程不安全的,切忌切忌!
  8. AtCoder Regular Contest 067 F - Yakiniku Restaurants
  9. MATLAB运行edge函数闪退
  10. 解决IIS8中 URLRewriter 不能使用的方法