ARC文档中的相关术语介绍与举例

2019-02-15  本文已影响13人  传说中的汽水枪

此篇文章是描述Objective-C Automatic Reference Counting (ARC)中的相关术语

持续更新中.....

function

翻译:函数
解释:不属于任何一个类的方法,就是C语言中的函数
举例:

void printString(NSString *string) {
    NSLog(@"%@", string);
}

method

翻译:方法
解释:属于类的方法,包括对象方法和类方法
举例:

@implementation RXARCGlossaryObject
// Objective-C类中的instance method 或者 class method 叫做 method(方法)
+ (void)classMethodTest
{
}
- (void)instanceTest
{
}
@end

retainable object pointer (retainable pointer)

翻译: 可保持对象指针
解释: 就是iOS的一个对象指针
举例:

// 以下的三种都是 retainable object pointer
@property (nonatomic, copy) void(^block)(void);
@property (nonatomic, strong) NSObject *object;
@property (nonatomic, strong) __attribute__((NSObject)) CFStringRef stringRef;

retainable object pointer type (retainable type) (retainable pointer type)

翻译: 可保持对象指针类型
解释: 就是iOS的一个对象指针类型
举例:
相当于上面的例子就是:

void(^)(void)
NSObject *

non-retainable object pointer type (non-retainable pointer type)

翻译:非可保持指针类型
举例:

CFStringRef
CFDictionaryRef

也可以参考相关介绍这些非可保持指针类型:
CoreFounction框架相关

object point type

翻译:对象指针类型
解释(来源于Objective-C Automatic Reference Counting (ARC)):

Objective-C defines a new type kind, collectively called the object pointer types. This kind has two notable builtin members, id and Class; id is the final supertype of all object pointers. The validity of conversions between object pointer types is not checked at runtime. Users may define classes; each class is a type, and the pointer to that type is an object pointer type. A class may have a superclass; its pointer type is a subtype of its superclass’s pointer type. A class has a set of ivars, fields which appear on all instances of that class. For every class T there’s an associated metaclass; it has no fields, its superclass is the metaclass of T’s superclass, and its metaclass is a global class. Every class has a global object whose class is the class’s metaclass; metaclasses have no associated type, so pointers to this object have type Class.

举例:

id
Class

callee 和 caller

翻译:callee(被调用者) caller(调用者)
举例:

- (void)_caller
{
    [self _callee];
}
- (void)_callee
{
}

Computation history

In computer science, a computation history is a sequence of steps taken by an abstract machine in the process of computing its result. Computation histories are frequently used in proofs about the capabilities of certain machines, and particularly about the undecidability of various formal languages.

上一篇 下一篇

猜你喜欢

热点阅读