Question

i want to create and observer that checks for a change in proximity sensor. i am using this code.

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(proximityChanged:) name:@"UIDeviceProximityStateDidChangeNotification" object:device];

but it give an error of "Use of undeclared identifier 'device'"

please help.

Was it helpful?

Solution

[[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(proximityChanged:)
                                                     name:@"UIDeviceProximityStateDidChangeNotification"
                                                   object:nil];

Do like this way you set nil to objcet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top