Questions tagged [addobserver]
64 questions
1
vote
1 answer
Calling lifecycle.addObserver from a Kotlin abstract class
I have an abstract class that implements DefaultLifecycleObserver. I'd like to call lifecycle.addObserver(this) from the init block, but it says "Leaking 'this' in constructor of non-final class MyAbstractClass".
My code:
abstract class…

Hadas Kaminsky
- 1,285
- 1
- 16
- 39
1
vote
1 answer
NSNotification.Name.NSExtensionHostWillEnterForeground does not work
I can use NSNotification in last version of Xcode 11.1.
I can trying to update fields values with a my function refreshFields() after returning to the app from background.
My code compiles successfully, but function applicationWillEnterForeground()…

DEN
- 21
- 3
1
vote
2 answers
NotificationCenter.default.addObserver keep getting called multiple times with Unwind Segue
I am using an show segue and an unwind segue to navigate between two iOS viewControllers, VC1 and VC2. In the viewDidLoad() of VC2 I make VC2 an observer. Here is my code:
override func viewDidLoad() {
super.viewDidLoad()
…

Pat Dolan
- 41
- 6
1
vote
0 answers
AddObserver for device orientation with tab bar controller
I have got 5 tabs bar, all tabs bar come with navigation controller on it except for 3rd tab bar, there is a custom view to make it same as navigation controller bar. Inside of the custom has textfield and button. So I was trying to make the same…

Andrew
- 75
- 1
- 6
1
vote
1 answer
ios swift 3 addObserver how to redirect to a certain view from anywhere in the app when push notification tapped
I have an application which has tabBar with 5 tabs
first one let's call it "FirstView" - has following code:
override func viewWillAppear(_ animated: Bool) {
...
NotificationCenter.default.addObserver(self, selector:…

Gulz
- 1,773
- 19
- 15
1
vote
1 answer
NSNotification listening
I have multiple instances of NSWindowController, who is registering for a notification to listen whenever edit happens.
Now when I edit something from one instance of windowcontroller, the notification gets posted and all the instances of that…

subhash Amale
- 325
- 3
- 4
- 14
1
vote
1 answer
Swift 2 addObserver for specific UITextfield with object parameter
I'd like to call a function if a specific UITextField was tapped:
As far as I understand the following code works for notifications, which comes from the window:
NSNotificationCenter.defaultCenter().addObserver(self, selector:…

AlexWoe89
- 844
- 1
- 11
- 23
1
vote
1 answer
Swift class error WKWebView was deallocated while key value observers were still registered with it
I have a problem removing observer from my viewController named "myBrowser". I have a ProgressView bar, Here is the code where i add the observer:
webView!.addObserver(self, forKeyPath: "estimatedProgress", options: .New, context: nil)
in this…

Swift1
- 349
- 1
- 4
- 22
1
vote
1 answer
Why might this [Swift] NSObject.addObserver registration not be calling func observeValueForKeyPath() as expected?
Problematic code follows. [I hope that] the problem is wholly outlined in the question above. Thanks in advance. MJB.
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate
{
var some_string:NSString = "one"
func…

Joseph Beuys' Mum
- 2,395
- 2
- 24
- 50
1
vote
2 answers
AVPlayer status: message was received but not handled
I'm pretty new to observers and Swift/ObjC, and I'm trying to monitor AVPlayer status using one as said in Apple's documentation, but everything I get is a "message was received but not handled" error message when I try to add the…

Greensouth
- 41
- 1
- 9
1
vote
1 answer
object in addObserver is different
I'm have the following code:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerWillEnterFullscreen:)
name:MPMoviePlayerWillEnterFullscreenNotification
…

Boaz
- 4,864
- 12
- 50
- 90
1
vote
1 answer
removeObserver crashing my app even though appears to be balanced with addObserver
So I have a class, CustomCell : UITableViewCell with a single addObserver:forKeyPath:options:context: method, called in -awakeFromNib, and a single removeObserver:forKeyPath:context: method, called in -dealloc.
CustomCell.m
static void * const…

max_jf5
- 169
- 1
- 12
1
vote
2 answers
NSNotificationCenter addObserver being ignored
Two objects were working just fine receiving NSNotifications before with XCode 5.1 (and CorePlot 1.4). However, with XCode 5.1.1 (Coreplot 1.5) I found that if the addObserver call is inside the init method, it won't actually be registered (just…

Adam Jones
- 775
- 6
- 23
1
vote
2 answers
NSNotification register place issue
I have a tab bar application in which there are 2 tabs(2 view controllers). I need to post notification from tab 2(view controller 2) to tab 1(view controller 1). But the problem is that i have to necessarily first go to tab 1(view controller 1) in…

user2268539
- 173
- 2
- 3
- 14
1
vote
2 answers
AVPlayer observeValueForKeyPath
I have an audio app that plays stream content. Problem is sometimes, when signal is weak, it stops playing. The network is still reachable, but the buffer seems to have run empty.
I tried implementing an observer to monitor the player' status…

Patrice Cote
- 3,572
- 12
- 43
- 72