[ad_1]
I wish to do some operations by clicking the amount button. I can do that within the following methods
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChangeNotification:)title:@"SystemVolumeDidChange" object:nil];
- (void)volumeChangeNotification:(NSNotification *)notification {
//do one thing
}
However I discovered a puzzling phenomenon. Click on the amount key as soon as, and the monitoring occasion will probably be referred to as twice. I attempt to delete the listener on the finish of the listener perform ,like this
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(volumeChangeNotification:)title:@"SystemVolumeDidChange" object:nil];
- (void)volumeChangeNotification:(NSNotification *)notification {
//do one thing
[[NSNotificationCenter defaultCenter] removeObserver:self title:@"SystemVolumeDidChange" object:nil];
}
Then I activate the monitor after 1 second, however it additionally would not work. What ought to I do?thanks verymuch
[ad_2]
