I have a custom UIImageView class that I want to use to control my UIImageViews.
Inside the custom init method I have the following regarding the UIAccelerometer:
UIAccelerometer *accelerometer = [UIAccelerometer sharedAccelerometer];
accelerometer.updateInterval = 0.5f;
accelerometer.delegate = self;
My problem is that I have multiple instances of this class and the accelerometer only sends information to the last instance I create. I know the reason for this is because the delegate is being set to the last instance, so my question is:
Is there a way to set the delegate to all of these instances so all of them receive the "didAccelerate" call? If so then how would I go about it.
Disclaimer: the method you're trying to use is deprecated. Use
CMMotionManager
instead. However:Set one delegate (it should be a separate class), then use NSNotificationCenter to distribute the information to the other listeners. Example:
Then in your listener class: