key-value-observing

Swift -AVPlayer' KVO in cell's parent vc causing Xcode to freeze

耗尽温柔 提交于 2021-01-28 03:55:42
问题 I have a cell that takes up the entire screen so there is only 1 visible cell at a time. Inside the cell I have an AVPlayer. Inside the cell's parent vc I have a KVO observer that listens to the "timeControlStatus" . When the player stops playing I call a function stopVideo() inside the cell to stop the player and either show a replay button or a play button etc. 3 problems: 1- When the video stops/reaches end if I don't use DispatchQueue inside the KVO the app crashes when the cell's

Swift -AVPlayer' KVO in cell's parent vc causing Xcode to freeze

冷暖自知 提交于 2021-01-27 22:43:56
问题 I have a cell that takes up the entire screen so there is only 1 visible cell at a time. Inside the cell I have an AVPlayer. Inside the cell's parent vc I have a KVO observer that listens to the "timeControlStatus" . When the player stops playing I call a function stopVideo() inside the cell to stop the player and either show a replay button or a play button etc. 3 problems: 1- When the video stops/reaches end if I don't use DispatchQueue inside the KVO the app crashes when the cell's

Swift -AVPlayer' KVO in cell's parent vc causing Xcode to freeze

折月煮酒 提交于 2021-01-27 20:51:02
问题 I have a cell that takes up the entire screen so there is only 1 visible cell at a time. Inside the cell I have an AVPlayer. Inside the cell's parent vc I have a KVO observer that listens to the "timeControlStatus" . When the player stops playing I call a function stopVideo() inside the cell to stop the player and either show a replay button or a play button etc. 3 problems: 1- When the video stops/reaches end if I don't use DispatchQueue inside the KVO the app crashes when the cell's

Swift 4 switch to new observe API

百般思念 提交于 2020-06-26 04:30:47
问题 I am having trouble with the new observe API in Swift 4. player = AVPlayer() player?.observe(\.currentItem.status, options: [.new], changeHandler: { [weak self] (player, newValue) in if let status = AVPlayer.Status(rawValue: (newValue as! NSNumber).intValue) { } } But I get an error Type of expression is ambiguous without more context. How do I fix it? Not sure about keyPath syntax. There is also a warning in extracting AVPlayerStatus in the closure above Cast from 'NSKeyValueObservedChange'

KVO not working with UISwitch

大城市里の小女人 提交于 2020-04-10 14:11:40
问题 For the life of me I can't get KVO working with UISwitch. I have a custom UITableViewCell with a UISwitch added through Interface Builder. I created an IBOutlet for the UISwitch and linked it to theSwitch variable. - (id)initWithCoder:(NSCoder *)coder { self = [super initWithCoder:coder]; if (self) { [theSwitch addObserver:self forKeyPath:@"on" options:NSKeyValueObservingOptionNew context:NULL]; } return self; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:

KVO not working with UISwitch

冷暖自知 提交于 2020-04-10 14:09:37
问题 For the life of me I can't get KVO working with UISwitch. I have a custom UITableViewCell with a UISwitch added through Interface Builder. I created an IBOutlet for the UISwitch and linked it to theSwitch variable. - (id)initWithCoder:(NSCoder *)coder { self = [super initWithCoder:coder]; if (self) { [theSwitch addObserver:self forKeyPath:@"on" options:NSKeyValueObservingOptionNew context:NULL]; } return self; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:

KVO not working with UISwitch

最后都变了- 提交于 2020-04-10 14:09:05
问题 For the life of me I can't get KVO working with UISwitch. I have a custom UITableViewCell with a UISwitch added through Interface Builder. I created an IBOutlet for the UISwitch and linked it to theSwitch variable. - (id)initWithCoder:(NSCoder *)coder { self = [super initWithCoder:coder]; if (self) { [theSwitch addObserver:self forKeyPath:@"on" options:NSKeyValueObservingOptionNew context:NULL]; } return self; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:

KVO not working with UISwitch

人走茶凉 提交于 2020-04-10 14:07:41
问题 For the life of me I can't get KVO working with UISwitch. I have a custom UITableViewCell with a UISwitch added through Interface Builder. I created an IBOutlet for the UISwitch and linked it to theSwitch variable. - (id)initWithCoder:(NSCoder *)coder { self = [super initWithCoder:coder]; if (self) { [theSwitch addObserver:self forKeyPath:@"on" options:NSKeyValueObservingOptionNew context:NULL]; } return self; } - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change: