Bläddra i källkod

Fix tag selectors name and type conflict

Christopher Atlan 5 år sedan
förälder
incheckning
b15acac803

+ 1 - 1
Documentation/CustomContext.md

@@ -33,7 +33,7 @@ Every log message that goes through the Lumberjack framework is turned into a DD
 @property (readonly, nonatomic) NSString *fileName;
 @property (readonly, nonatomic) NSString *function;
 @property (readonly, nonatomic) NSUInteger line;
-@property (readonly, nonatomic) id tag;
+@property (readonly, nonatomic) id representedObject;
 @property (readonly, nonatomic) DDLogMessageOptions options;
 @property (readonly, nonatomic) NSDate *timestamp;
 @property (readonly, nonatomic) NSString *threadID; // ID as it appears in NSLog calculated from the machThreadID

+ 1 - 1
Documentation/CustomLoggers.md

@@ -128,7 +128,7 @@ The DDLogMessage object encapsulates the information about a log message. It is
 @property (readonly, nonatomic) NSString *fileName;
 @property (readonly, nonatomic) NSString *function;
 @property (readonly, nonatomic) NSUInteger line;
-@property (readonly, nonatomic) id tag;
+@property (readonly, nonatomic) id representedObject;
 @property (readonly, nonatomic) DDLogMessageOptions options;
 @property (readonly, nonatomic) NSDate *timestamp;
 @property (readonly, nonatomic) NSString *threadID; // ID as it appears in NSLog calculated from the machThreadID

+ 4 - 0
Sources/CocoaLumberjack/DDLog.m

@@ -1015,6 +1015,10 @@ NSString * __nullable DDExtractFileNameWithoutExtension(const char *filePath, BO
 
 @implementation DDLogMessage
 
+// Fix @selectors name and type conflict from AppKit/UIKit (e.g. views NSInteger tag property)
+// without refactoring DDLog interal code.
+@synthesize representedObject = _tag;
+
 - (instancetype)init {
     self = [super init];
     return self;

+ 1 - 1
Sources/CocoaLumberjack/include/CocoaLumberjack/DDLog.h

@@ -845,7 +845,7 @@ typedef NS_OPTIONS(NSInteger, DDLogMessageOptions){
 @property (readonly, nonatomic) NSString *fileName;
 @property (readonly, nonatomic, nullable) NSString * function;
 @property (readonly, nonatomic) NSUInteger line;
-@property (readonly, nonatomic, nullable) id tag;
+@property (readonly, nonatomic, nullable) id representedObject;
 @property (readonly, nonatomic) DDLogMessageOptions options;
 @property (readonly, nonatomic) NSDate *timestamp;
 @property (readonly, nonatomic) NSString *threadID; // ID as it appears in NSLog calculated from the machThreadID

+ 2 - 2
Tests/CocoaLumberjackTests/DDLogMessageTests.m

@@ -136,7 +136,7 @@ static NSString * const kDefaultMessage = @"Log message";
     XCTAssertEqualObjects(self.message.file, @"DDLogMessageTests.m");
     XCTAssertEqualObjects(self.message.function, @"testInitSetsAllPassedParameters");
     XCTAssertEqual(self.message.line, 50);
-    XCTAssertEqualObjects(self.message.tag, NULL);
+    XCTAssertEqualObjects(self.message.representedObject, NULL);
     XCTAssertEqual(self.message.options, DDLogMessageCopyFile);
     XCTAssertEqualObjects(self.message.timestamp, referenceDate);
 }
@@ -221,7 +221,7 @@ static NSString * const kDefaultMessage = @"Log message";
     XCTAssertEqualObjects(self.message.fileName, copy.fileName);
     XCTAssertEqualObjects(self.message.function, copy.function);
     XCTAssertEqual(self.message.line, copy.line);
-    XCTAssertEqualObjects(self.message.tag, copy.tag);
+    XCTAssertEqualObjects(self.message.representedObject, copy.representedObject);
     XCTAssertEqual(self.message.options, copy.options);
     XCTAssertEqualObjects(self.message.timestamp, copy.timestamp);
     XCTAssertEqualObjects(self.message.threadID, copy.threadID);