Skip to content

Commit 4219b78

Browse files
mlch911p-x9
andauthoredNov 28, 2024
Update Sources/AssociatedObjectPlugin/AssociatedObjectMacro.swift
Co-authored-by: p-x9 <chi.iosdev@gmail.com>
1 parent 635675b commit 4219b78

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed
 

‎Sources/AssociatedObjectPlugin/AssociatedObjectMacro.swift

+9-16
Original file line numberDiff line numberDiff line change
@@ -330,24 +330,17 @@ extension AssociatedObjectMacro {
330330
"let oldValue = \(identifier)"
331331
}
332332

333+
"""
334+
setAssociatedObject(
335+
self,
336+
\(associatedKey),
337+
newValue,
338+
\(policy)
339+
)
340+
"""
333341
if type.isOptional, hasDefaultValue {
334342
"""
335-
setAssociatedObject(
336-
self,
337-
\(associatedKey),
338-
newValue,
339-
\(policy)
340-
)
341-
self.__associated_\(identifier.trimmed)IsSet = true
342-
"""
343-
} else {
344-
"""
345-
setAssociatedObject(
346-
self,
347-
\(associatedKey),
348-
newValue,
349-
\(policy)
350-
)
343+
self.__associated_\(identifier.trimmed)IsSet = true
351344
"""
352345
}
353346

0 commit comments

Comments
 (0)