Skip to content

VLCKit: Change the notification name from NSString to NSNotificationName and unify the naming convention

Hank Anderson requested to merge Sumou/VLCKit:notification-name-refactor into master

Change the notification name from NSString to NSNotificationName and unify the naming convention.

before

// Obj-C
NSString *name = VLCMediaPlayerTimeChanged;
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(method) name: name object: nil];
// Swift
let name: Notification.Name = .init(rawValue: VLCMediaPlayerTimeChanged)
NotificationCenter.default.addObserver(self, selector: #selector(method), name: name, object: nil)

after

// Obj-C
NSNotificationName name = VLCMediaPlayerTimeChangedNotification;
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(method) name: name object: nil];
// Swift
let name: NSNotification.Name = VLCMediaPlayer.timeChangedNotification
NotificationCenter.default.addObserver(self, selector: #selector(method), name: name, object: nil)

Referenced implementation of Apple Framework

// Obj-C
NSNotificationName name = UIApplicationDidBecomeActiveNotification;
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(method) name: name object: nil];
// Swift
let name: NSNotification.Name = UIApplication.didBecomeActiveNotification
NotificationCenter.default.addObserver(self, selector: #selector(method), name: name, object: nil)

best regards.

Edited by Felix Paul Kühne

Merge request reports

Loading