|
@@ -125,14 +125,14 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}];
|
|
}];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
NSArray<FLEXObjectRef *> *references = [FLEXObjectRef referencingAll:instances];
|
|
NSArray<FLEXObjectRef *> *references = [FLEXObjectRef referencingAll:instances];
|
|
|
if (references.count == 1) {
|
|
if (references.count == 1) {
|
|
|
return [FLEXObjectExplorerFactory
|
|
return [FLEXObjectExplorerFactory
|
|
|
explorerViewControllerForObject:references.firstObject.object
|
|
explorerViewControllerForObject:references.firstObject.object
|
|
|
];
|
|
];
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
FLEXObjectListViewController *controller = [[self alloc] initWithReferences:references];
|
|
FLEXObjectListViewController *controller = [[self alloc] initWithReferences:references];
|
|
|
controller.title = [NSString stringWithFormat:@"%@ (%lu)", className, (unsigned long)instances.count];
|
|
controller.title = [NSString stringWithFormat:@"%@ (%lu)", className, (unsigned long)instances.count];
|
|
|
return controller;
|
|
return controller;
|
|
@@ -145,7 +145,7 @@
|
|
|
controller.title = [NSString stringWithFormat:@"Subclasses of %@ (%lu)",
|
|
controller.title = [NSString stringWithFormat:@"Subclasses of %@ (%lu)",
|
|
|
className, (unsigned long)classes.count
|
|
className, (unsigned long)classes.count
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return controller;
|
|
return controller;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -158,7 +158,7 @@
|
|
|
SwiftObjectClass = NSClassFromString(@"Swift._SwiftObject");
|
|
SwiftObjectClass = NSClassFromString(@"Swift._SwiftObject");
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
NSMutableArray<FLEXObjectRef *> *instances = [NSMutableArray new];
|
|
NSMutableArray<FLEXObjectRef *> *instances = [NSMutableArray new];
|
|
|
[FLEXHeapEnumerator enumerateLiveObjectsUsingBlock:^(__unsafe_unretained id tryObject, __unsafe_unretained Class actualClass) {
|
|
[FLEXHeapEnumerator enumerateLiveObjectsUsingBlock:^(__unsafe_unretained id tryObject, __unsafe_unretained Class actualClass) {
|
|
|
// Get all the ivars on the object. Start with the class and and travel up the inheritance chain.
|
|
// Get all the ivars on the object. Start with the class and and travel up the inheritance chain.
|
|
@@ -167,15 +167,15 @@
|
|
|
while (tryClass) {
|
|
while (tryClass) {
|
|
|
unsigned int ivarCount = 0;
|
|
unsigned int ivarCount = 0;
|
|
|
Ivar *ivars = class_copyIvarList(tryClass, &ivarCount);
|
|
Ivar *ivars = class_copyIvarList(tryClass, &ivarCount);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for (unsigned int ivarIndex = 0; ivarIndex < ivarCount; ivarIndex++) {
|
|
for (unsigned int ivarIndex = 0; ivarIndex < ivarCount; ivarIndex++) {
|
|
|
Ivar ivar = ivars[ivarIndex];
|
|
Ivar ivar = ivars[ivarIndex];
|
|
|
NSString *typeEncoding = @(ivar_getTypeEncoding(ivar) ?: "");
|
|
NSString *typeEncoding = @(ivar_getTypeEncoding(ivar) ?: "");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (typeEncoding.flex_typeIsObjectOrClass) {
|
|
if (typeEncoding.flex_typeIsObjectOrClass) {
|
|
|
ptrdiff_t offset = ivar_getOffset(ivar);
|
|
ptrdiff_t offset = ivar_getOffset(ivar);
|
|
|
uintptr_t *fieldPointer = (__bridge void *)tryObject + offset;
|
|
uintptr_t *fieldPointer = (__bridge void *)tryObject + offset;
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (*fieldPointer == (uintptr_t)(__bridge void *)object) {
|
|
if (*fieldPointer == (uintptr_t)(__bridge void *)object) {
|
|
|
NSString *ivarName = @(ivar_getName(ivar) ?: "???");
|
|
NSString *ivarName = @(ivar_getName(ivar) ?: "???");
|
|
|
[instances addObject:[FLEXObjectRef referencing:tryObject ivar:ivarName]];
|
|
[instances addObject:[FLEXObjectRef referencing:tryObject ivar:ivarName]];
|
|
@@ -183,7 +183,7 @@
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
tryClass = class_getSuperclass(tryClass);
|
|
tryClass = class_getSuperclass(tryClass);
|
|
|
}
|
|
}
|
|
|
}];
|
|
}];
|
|
@@ -206,7 +206,7 @@
|
|
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
[super viewDidLoad];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
self.showsSearchBar = YES;
|
|
self.showsSearchBar = YES;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -224,7 +224,7 @@
|
|
|
- (NSArray *)buildSections:(NSArray<NSString *> *)titles predicates:(NSArray<NSPredicate *> *)predicates {
|
|
- (NSArray *)buildSections:(NSArray<NSString *> *)titles predicates:(NSArray<NSPredicate *> *)predicates {
|
|
|
NSParameterAssert(titles.count == predicates.count);
|
|
NSParameterAssert(titles.count == predicates.count);
|
|
|
NSParameterAssert(titles); NSParameterAssert(predicates);
|
|
NSParameterAssert(titles); NSParameterAssert(predicates);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return [NSArray flex_forEachUpTo:titles.count map:^id(NSUInteger i) {
|
|
return [NSArray flex_forEachUpTo:titles.count map:^id(NSUInteger i) {
|
|
|
NSArray *rows = [self.references filteredArrayUsingPredicate:predicates[i]];
|
|
NSArray *rows = [self.references filteredArrayUsingPredicate:predicates[i]];
|
|
|
return [self makeSection:rows title:titles[i]];
|
|
return [self makeSection:rows title:titles[i]];
|
|
@@ -241,18 +241,22 @@
|
|
|
if (ref.summary && [ref.summary localizedCaseInsensitiveContainsString:filterText]) {
|
|
if (ref.summary && [ref.summary localizedCaseInsensitiveContainsString:filterText]) {
|
|
|
return YES;
|
|
return YES;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
return [ref.reference localizedCaseInsensitiveContainsString:filterText];
|
|
return [ref.reference localizedCaseInsensitiveContainsString:filterText];
|
|
|
}
|
|
}
|
|
|
];
|
|
];
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
|
|
+ __weak __typeof(self) weakSelf = self;
|
|
|
section.selectionHandler = ^(__kindof UIViewController *host, FLEXObjectRef *ref) {
|
|
section.selectionHandler = ^(__kindof UIViewController *host, FLEXObjectRef *ref) {
|
|
|
- [self.navigationController pushViewController:[
|
|
|
|
|
- FLEXObjectExplorerFactory explorerViewControllerForObject:ref.object
|
|
|
|
|
- ] animated:YES];
|
|
|
|
|
|
|
+ __strong __typeof(self) strongSelf = weakSelf;
|
|
|
|
|
+ if (strongSelf) {
|
|
|
|
|
+ [strongSelf.navigationController pushViewController:[
|
|
|
|
|
+ FLEXObjectExplorerFactory explorerViewControllerForObject:ref.object
|
|
|
|
|
+ ] animated:YES];
|
|
|
|
|
+ }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- section.customTitle = title;
|
|
|
|
|
|
|
+ section.customTitle = title;
|
|
|
return section;
|
|
return section;
|
|
|
}
|
|
}
|
|
|
|
|
|