Skip to content

Commit

Permalink
Fix one more warning
Browse files Browse the repository at this point in the history
  • Loading branch information
testableapple committed Oct 20, 2023
1 parent 79b6f72 commit b4e13b3
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,16 @@ private final class ImageViewController {

// Lazily create a controller for a given view and associate it with a view.
static func controller(for view: ImageDisplayingView) -> ImageViewController {
if let controller = objc_getAssociatedObject(view, &ImageViewController.controllerAK) as? ImageViewController {
if let controller = withUnsafePointer(to: &ImageViewController.controllerAK, { keyPointer in
objc_getAssociatedObject(view, keyPointer) as? ImageViewController
}) {
return controller
}

let controller = ImageViewController(view: view)
objc_setAssociatedObject(view, &ImageViewController.controllerAK, controller, .OBJC_ASSOCIATION_RETAIN)
withUnsafePointer(to: &ImageViewController.controllerAK) { keyPointer in
objc_setAssociatedObject(view, keyPointer, controller, .OBJC_ASSOCIATION_RETAIN)
}
return controller
}

Expand Down

0 comments on commit b4e13b3

Please sign in to comment.