Closed mlch911 closed 9 months ago
Should re-run the CI.
When defined as follows,
class A {
@AssociatedObject(.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
var hello: String? = "default"
}
With this implementation, I think that a nil assignment would return the default value.
let a = A()
print(a.hello) // => default
a.hello = nil
print(a.hello) // => default
However, in the current main branch implementation, the default values are not reflected in the first acquisition as follows:
let a = A()
print(a.hello) // => nil
a.hello = "modified"
print(a.hello) // => modified
Therefore, I feel that we need to find a new way to implement this again.
In the meantime, since it is difficult to update test cases, we are planning to rewrite the tests using the following library.
The following branch resolved the above issue.
https://github.com/p-x9/AssociatedObject/pull/27
In addition, I thought it would be a better way to replace Wrapped!
with Wrapped?
in the case of ImplicitlyUnwrappedOptional.
(To avoid returning defaultValue
after assigning nil
)
That's better!
Xcode will give this an error.