This commit is contained in:
2025-10-28 10:18:10 +08:00
parent efb04d134e
commit 1deca2ae5b
166 changed files with 17288 additions and 1427 deletions

View File

@@ -0,0 +1,40 @@
#ifdef SHOULD_COMPILE_LOOKIN_SERVER
//
// LookinIvarTrace.h
// Lookin
//
// Created by Li Kai on 2019/4/30.
// https://lookin.work
//
#import <Foundation/Foundation.h>
extern NSString *const LookinIvarTraceRelationValue_Self;
/// 如果 hostClassName 和 ivarName 均 equal则认为两个 LookinIvarTrace 对象彼此 equal
/// 比如 A 是 B 的 superview且 A 的 "_stageView" 指向 B则 B 会有一个 LookinIvarTracehostType 为 “superview”hostClassName 为 A 的 classivarName 为 “_stageView”
@interface LookinIvarTrace : NSObject <NSSecureCoding, NSCopying>
/// 该值可能是 "superview"、"superlayer"、“self” 或 nil
@property(nonatomic, copy) NSString *relation;
@property(nonatomic, copy) NSString *hostClassName;
@property(nonatomic, copy) NSString *ivarName;
#pragma mark - No Coding
#if TARGET_OS_IPHONE
@property(nonatomic, weak) id hostObject;
#endif
@end
@interface NSObject (LookinServerTrace)
@property(nonatomic, copy) NSArray<LookinIvarTrace *> *lks_ivarTraces;
@end
#endif /* SHOULD_COMPILE_LOOKIN_SERVER */

View File

@@ -0,0 +1,70 @@
#ifdef SHOULD_COMPILE_LOOKIN_SERVER
//
// LookinIvarTrace.m
// Lookin
//
// Created by Li Kai on 2019/4/30.
// https://lookin.work
//
#import "LookinIvarTrace.h"
NSString *const LookinIvarTraceRelationValue_Self = @"self";
@implementation LookinIvarTrace
#pragma mark - Equal
- (NSUInteger)hash {
return self.hostClassName.hash ^ self.ivarName.hash;
}
- (BOOL)isEqual:(id)object {
if (self == object) {
return YES;
}
if (![object isKindOfClass:[LookinIvarTrace class]]) {
return NO;
}
LookinIvarTrace *comparedObj = object;
if ([self.hostClassName isEqualToString:comparedObj.hostClassName] && [self.ivarName isEqualToString:comparedObj.ivarName]) {
return YES;
}
return NO;
}
#pragma mark - <NSCopying>
- (id)copyWithZone:(NSZone *)zone {
LookinIvarTrace *newTrace = [[LookinIvarTrace allocWithZone:zone] init];
newTrace.relation = self.relation;
newTrace.hostClassName = self.hostClassName;
newTrace.ivarName = self.ivarName;
return newTrace;
}
#pragma mark - <NSCoding>
- (void)encodeWithCoder:(NSCoder *)aCoder {
[aCoder encodeObject:self.relation forKey:@"relation"];
[aCoder encodeObject:self.hostClassName forKey:@"hostClassName"];
[aCoder encodeObject:self.ivarName forKey:@"ivarName"];
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
if (self = [super init]) {
self.relation = [aDecoder decodeObjectForKey:@"relation"];
self.hostClassName = [aDecoder decodeObjectForKey:@"hostClassName"];
self.ivarName = [aDecoder decodeObjectForKey:@"ivarName"];
}
return self;
}
+ (BOOL)supportsSecureCoding {
return YES;
}
@end
#endif /* SHOULD_COMPILE_LOOKIN_SERVER */