I am posting notification from UIViewController object to UIView object. Notification is called but its method "playSound" is not called.
Below is my code and Thanks in Advance :
@interface SettingsViewController : UIViewController <MFMailComposeViewControllerDelegate>
{
MFMailComposeViewController *mailComposer;
}
- (IBAction)btnSoundClicked:(id)sender {
if(self.btnSound.on)
{
NSLog(@"Swith On");
[[NSNotificationCenter defaultCenter] postNotificationName:@"soundStatus" object:self.btnSound];
}
else
{
NSLog(@"Switch Off");
}
}
@interface IAPuzzleBoardView : UIView <AVAudioPlayerDelegate> {
}
- (void)movingThisTile:(CGPoint)tilePoint {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playSound:)
name:@"soundStatus"
object:nil];
}
-(void) playSound : (NSNotification *) notification
{
if ([[notification name] isEqualToString:@"soundStatus"])
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"move" ofType:@"wav"];
theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
}
}