注册页面---------------
//在通知中心注册通知
[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(receive:)name:@"receive"object:nil];
[play.btnaddTarget:selfaction:@selector(playMusic)forControlEvents:UIControlEventTouchUpInside];
// Do any additional setup after loading the view.
}
-(void)receive:(NSNotification*)noti
{
play.btn.selected=NO;
dic= noti.object;
NSString*path = [[NSBundlemainBundle]pathForResource:[dicobjectForKey:@"name"]ofType:@"mp3"];
NSURL*url = [NSURLfileURLWithPath:path];
play1= [[AVAudioPlayeralloc]initWithContentsOfURL:urlerror:nil];
play.current.text=[selfchangeTime:play1.currentTime];
play.duration.text= [selfchangeTime:play1.duration];
self.navigationItem.title= [dicobjectForKey:@"name"];
}
使用界面-----------
//给消息中心发通知
[[NSNotificationCenterdefaultCenter]postNotificationName:@"receive"object:[arrobjectAtIndex:indexPath.row]];