NSCopying for NSDate variable broken in iOS13

After copy, when we do Pointer difference check ,for NSDate variable failed.

@interface TestDef : NSObject<NSCopying>

...


TestDef *original = [[TestDef alloc] init];

TestDef *copied = [original copy];

XCTAssertNotEqual(original.Date, copied.Date);

Replies

After copy, when we do Pointer difference check, for NSDate variable failed.

Your test isn’t valid.

NSDate
objects are immutable, so
-copy
is allowed to just increment the reference count. Moreover, on modern systems you’ll find that
NSDate
is actually implemented using tagged pointers, so it doesn’t even allocate memory.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"