-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFGInternal.m
48 lines (40 loc) · 1.08 KB
/
FGInternal.m
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
//
// FGInternal.m
// FastGuiKit
//
// Created by 易元 白 on 15/3/3.
// Copyright (c) 2015年 eldereal. All rights reserved.
//
#import "FGInternal.h"
@implementation FGInternal
/**
* return the direct caller's position as reuse id
*/
+ (NSString *) callerPositionAsReuseId
{
//return [NSThread callStackSymbols][2];
NSArray *arr = [NSThread callStackReturnAddresses];
if (arr.count < 3) {
return @"_caller@unavailable";
}
NSNumber *val = arr[2];
return [NSString stringWithFormat:@"_caller@%lx", val.longValue];
}
+ (NSString *)herePositionAsReuseId
{
NSArray *arr = [NSThread callStackReturnAddresses];
NSNumber *val = arr[1];
return [NSString stringWithFormat:@"_caller@%lx", val.longValue];
}
+ (NSString *)memoryPositionAsReuseIdOfObject:(id)obj
{
return [NSString stringWithFormat:@"_object@%lx", (unsigned long) obj];
}
+ (NSString *) staticReuseId: (__strong NSString **) pointer
{
if (*pointer == nil) {
* pointer = [NSString stringWithFormat:@"_static@%lx", (unsigned long) pointer];
}
return *pointer;
}
@end