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.

Était-ce utile?

La solution

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

Do like this way you set nil to objcet.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top