MyCustomView.m
{
-(IBAction)buttonPlay{
`Add observer for AVPlayer`
}
-(void)dealloc{
`Remove Observer for AVPlayer`
}
}
MYViewController.m
{
for (i=0;i<10;i++){
myCustomView *m = [[myCustomView alloc]init];
[arrlist addobject:m];
}
-(void)reset{
[arrList remove allObjects]; //**Crash the app**
}
}
如何从数组中删除对象。 我已经在dealloc方法中删除了观察者,但它仍然没有工作......
感谢您宝贵的时间
答案 0 :(得分:0)
dealloc
不会在ARC
环境中调用。而不是像下面那样放置通知观察者
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:self.playerItem];