runtime 一、objc_msgSend消息详解

参考资料

1、罗朝辉 深入浅出 Cocoa 之消息
2、Objective-C 中的元类(meta class)是什么?
3、小萝莉说crash

Mehr lesen

Block的实现

block的实现

[block的调试参考:]
(http://iosre.com/t/dispatch-async-queue-block-block/1234)

Mehr lesen

AVPlayer

前言


需要实现播放器功能,需求比较复杂,所以使用AVPlayer来自定义。
研究方法:

  1. 阅读AVFoundation Programming Guide,阅读相关类的头文件(AVPlayer,AVAssets,AVPlayItem)

Mehr lesen

iOS高级动画

寄宿图

CALayer类能够包含一个背景图片,这个背景图片就是寄宿图。

1
layer.contents = (__bridge id)image.CGImage;

Mehr lesen

重签名

最简单方案

注意:在重签名之前要把从appStore上下载的app砸壳

http://bbs.iosre.com/t/topic/2966

Mehr lesen

LLDB与debugserver

LLDB是Xcode内置的动态调试工具。debugserver运行在iOS上,他作为服务端实际执行LLDB传过来的命令,显示给用户,即所谓的”远程调试”。注意,设备只有连电脑真机测试过APP了,debugserver才会安装进设备的/Developer/usr/bin目录下。但是由于缺少 task_for_pid权限,通过Xcode安装的debugserver只能调试自己的app。想要调试别人的App要做下面的这些步骤配置:

Mehr lesen

可变参数

翻看Masonry的源码, 跟踪 #define mas_equalTo(...) equalTo(MASBoxValue((__VA_ARGS__))) 的时候看到有这样的一段代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
 /**
* Given a scalar or struct value, wraps it in NSValue
* Based on EXPObjectify: https://github.com/specta/expecta
*/
static inline id _MASBoxValue(const char *type, ...) {
va_list v;
va_start(v, type);
id obj = nil;
if (strcmp(type, @encode(id)) == 0) {
id actual = va_arg(v, id);
obj = actual;
} else if (strcmp(type, @encode(CGPoint)) == 0) {
CGPoint actual = (CGPoint)va_arg(v, CGPoint);
obj = [NSValue value:&actual withObjCType:type];
} else if (strcmp(type, @encode(CGSize)) == 0) {
CGSize actual = (CGSize)va_arg(v, CGSize);
obj = [NSValue value:&actual withObjCType:type];
} else if (strcmp(type, @encode(MASEdgeInsets)) == 0) {
MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets);
obj = [NSValue value:&actual withObjCType:type];
} else if (strcmp(type, @encode(double)) == 0) {
double actual = (double)va_arg(v, double);
obj = [NSNumber numberWithDouble:actual];
} else if (strcmp(type, @encode(float)) == 0) {
float actual = (float)va_arg(v, double);
obj = [NSNumber numberWithFloat:actual];
} else if (strcmp(type, @encode(int)) == 0) {
int actual = (int)va_arg(v, int);
obj = [NSNumber numberWithInt:actual];
} else if (strcmp(type, @encode(long)) == 0) {
long actual = (long)va_arg(v, long);
obj = [NSNumber numberWithLong:actual];
} else if (strcmp(type, @encode(long long)) == 0) {
long long actual = (long long)va_arg(v, long long);
obj = [NSNumber numberWithLongLong:actual];
} else if (strcmp(type, @encode(short)) == 0) {
short actual = (short)va_arg(v, int);
obj = [NSNumber numberWithShort:actual];
} else if (strcmp(type, @encode(char)) == 0) {
char actual = (char)va_arg(v, int);
obj = [NSNumber numberWithChar:actual];
} else if (strcmp(type, @encode(bool)) == 0) {
bool actual = (bool)va_arg(v, int);
obj = [NSNumber numberWithBool:actual];
} else if (strcmp(type, @encode(unsigned char)) == 0) {
unsigned char actual = (unsigned char)va_arg(v, unsigned int);
obj = [NSNumber numberWithUnsignedChar:actual];
} else if (strcmp(type, @encode(unsigned int)) == 0) {
unsigned int actual = (unsigned int)va_arg(v, unsigned int);
obj = [NSNumber numberWithUnsignedInt:actual];
} else if (strcmp(type, @encode(unsigned long)) == 0) {
unsigned long actual = (unsigned long)va_arg(v, unsigned long);
obj = [NSNumber numberWithUnsignedLong:actual];
} else if (strcmp(type, @encode(unsigned long long)) == 0) {
unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long);
obj = [NSNumber numberWithUnsignedLongLong:actual];
} else if (strcmp(type, @encode(unsigned short)) == 0) {
unsigned short actual = (unsigned short)va_arg(v, unsigned int);
obj = [NSNumber numberWithUnsignedShort:actual];
}
va_end(v);
return obj;
}

#define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value))

Mehr lesen

Xcode Tips

Xcode的一些小技巧

展开某个.m文件的所有宏

1
在Xcode中,选择Product -> Perform Action -> Preprocess "xxxxxx.m"

Mehr lesen

ARM汇编一些基础知识

32位

一、寄存器、内存和、栈

在高级语言里面,操作的是变量。在ARM汇编里面,操作的是寄存器(register)、内存和栈(stack)。

Mehr lesen

Cycript 注入测试函数

简介:
安装了Cycript后,可以用Objective-javascript的方式编写代码。可以从MTerminal中执行Cycript,也可以ssh到设备,执行Cycript。支持Objective-C的语法,部分也需要JavaScript的语法来写。详细参考官网地址
Cycript不是用来编写App,是用来测试函数的功能的工具。一般来说,选择注入哪个进程,要依测试的具体函数而定。

Mehr lesen