Skip to content

Commit 75271fc

Browse files
committed
Fix issues using a string as an observer context
Full warning: > MediaProgressCoordinator.swift:54:128 Forming 'UnsafeMutableRawPointer' to an inout variable of type String exposes the internal representation rather than the string contents.
1 parent 501dc8e commit 75271fc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

WordPress/Classes/ViewRelated/Aztec/Media/MediaProgressCoordinator.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class MediaProgressCoordinator: NSObject {
3232
return [String: Progress]()
3333
}()
3434

35-
private var mediaProgressObserverContext: String = "mediaProgressObserverContext"
35+
private static var mediaProgressObserverContext = 0
3636

3737
deinit {
3838
mediaGlobalProgress?.removeObserver(self, forKeyPath: #keyPath(Progress.fractionCompleted))
@@ -51,7 +51,7 @@ public class MediaProgressCoordinator: NSObject {
5151

5252
if mediaGlobalProgress == nil {
5353
mediaGlobalProgress = Progress.discreteProgress(totalUnitCount: 0)
54-
mediaGlobalProgress?.addObserver(self, forKeyPath: #keyPath(Progress.fractionCompleted), options: [.new], context: &mediaProgressObserverContext)
54+
mediaGlobalProgress?.addObserver(self, forKeyPath: #keyPath(Progress.fractionCompleted), options: [.new], context: &Self.mediaProgressObserverContext)
5555

5656
delegate?.mediaProgressCoordinatorDidStartUploading(self)
5757
}
@@ -263,7 +263,7 @@ public class MediaProgressCoordinator: NSObject {
263263

264264
public override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey: Any]?, context: UnsafeMutableRawPointer?) {
265265
guard
266-
context == &mediaProgressObserverContext,
266+
context == &Self.mediaProgressObserverContext,
267267
keyPath == #keyPath(Progress.fractionCompleted)
268268
else {
269269
super.observeValue(forKeyPath: keyPath,

0 commit comments

Comments
 (0)