In there a way to do this? I register my object for UIPasteboardChangedNotification
at launch time, but when sending it to the background and opening (for instance) Safari and copying some text, my handler never gets called.
(I'm using just the simulator for now).
I've used both:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(pasteboardNotificationReceived:)
name:UIPasteboardChangedNotification
object:[UIPasteboard generalPasteboard]];
and:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(pasteboardNotificationReceived:)
name:UIPasteboardChangedNotification
object:nil ];
to register my handler.
I had the same problem. According to the UIPasteboard Class Reference documentation for the
changeCount
property (emphasis is mine):I had read this to mean that my application would receive
UIPasteboardChangedNotification
notifications once my app was reactivated. A careful reading reveals, however, that it is only thechangeCount
that is updated when the app is reactivated.I dealt with this by tracking the pasteboard's
changeCount
in my app delegate and posting the expected notification when I find thechangeCount
has been changed while the app was in the background.In the app delegate's interface:
And in the app delegate's implementation: