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 方法中删除了观察器,但它仍然不起作用......
感谢您的宝贵时间
dealloc
不会在ARC
环境中调用。而不是像下面这样放置通知观察器
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:self.playerItem];