Thizzer
Thizzer

Reputation: 16663

NSNotificationCenter notifications of touch

Is there a notification type for the NSNotificationCenter thats allows you to be notified of any touches on the screen in any class? Or is there another way to solve this?

Upvotes: 1

Views: 1213

Answers (1)

Caleb
Caleb

Reputation: 125037

You could subclass UIWindow and override -sendEvent: such that it posts a notification or does some other processing on touch events before dispatching them to the appropriate view. (Call super's implementation of -sendEvent: to do dispatch the event.)

I'd avoid notifications for this purpose if you can, or at least be very careful to limit the number of objects listening to such a notification. Dragging a finger across the screen can generate a large number of events. Since any number of objects can subscribe to a notification, you could easily create a situation where the app gets bogged down in sending notifications.

Upvotes: 1

Related Questions