我在理解为什么会发生这种情况时遇到一些麻烦,但出于某些原因,当第二次触发NSNotification时会发生这种情况:
-[UITableViewCel lContentView imageFound:]: unrecognized selector sent to instance 0x1cd837e0 2013-08-12 16:32:24.340 poundtaxi[7483:907] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableViewCellContentView imageFound:]: unrecognized selector sent to instance 0x1cd837e0'
* 的第一掷调用堆栈:(0x344d92a3 0x3c17e97f 0x344dce07 0x344db531 0x34432f68 0x3442a037 0x34d40599 0xd7d9f 0x33d64145 0x3c59611f 0x3c5954b7 0x3c596dcb 0x344acf3b 0x3441febd 0x3441fd49 0x37fe32eb 0x36335301 0xb963d 0x3c5b5b20)的libc ++ abi.dylib:终止称为抛出异常< / p>
以下是执行的代码块:
-(void)imageFound:(NSNotification *)aNotification {
NSDictionary* userInfo = [aNotification userInfo];
Picture *aPicture = (Picture *) [userInfo objectForKey:@"picture"];
UIImage *image = (UIImage *) [userInfo objectForKey:@"image"];
aPicture.highResPicture = image;
self.count++;
}
答案 0 :(得分:1)
注册的观察者对象很可能在作为观察者被移除之前被释放。始终记得在dealloc中删除通知中心观察者。