Skip to content

Commit

Permalink
Remove warnings: objc_getAssociatedObject Forming 'UnsafeRawPointer' …
Browse files Browse the repository at this point in the history
…to an inout variable of type String exposes the internal representation rather than the string contents
  • Loading branch information
hboon committed Jun 7, 2024
1 parent e870048 commit bebaa02
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions AlphaWallet/Extensions/UIBarButtonItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,21 +130,29 @@ extension UIBarButtonItem {

var selectionClosure: ((UIBarButtonItem) -> Void)? {
get {
return objc_getAssociatedObject(self, &AssociatedObject.key) as? (UIBarButtonItem) -> Void
withUnsafePointer(to: AssociatedObject.key) {
return objc_getAssociatedObject(self, $0) as? (UIBarButtonItem) -> Void
}
}
set {
objc_setAssociatedObject(self, &AssociatedObject.key, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
withUnsafePointer(to: AssociatedObject.key) {
objc_setAssociatedObject(self, $0, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
target = self
action = #selector(didTapButton)
}
}

var gridOrListLayout: GridOrListLayout? {
get {
return objc_getAssociatedObject(self, &AssociatedObject.selectionState) as? GridOrListLayout
withUnsafePointer(to: AssociatedObject.selectionState) {
return objc_getAssociatedObject(self, $0) as? GridOrListLayout
}
}
set {
objc_setAssociatedObject(self, &AssociatedObject.selectionState, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
withUnsafePointer(to: AssociatedObject.selectionState) {
objc_setAssociatedObject(self, $0, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
}

Expand Down

0 comments on commit bebaa02

Please sign in to comment.