2012-07-18 31 views
5

Ben AsyncImageView.m dosyada, bu hatNSNotification EXC_BAD_ACCESS

[[NSNotificationCenter defaultCenter] postNotificationName:AsyncImageLoadDidFinish 
                 object:target 
                 userInfo:[[userInfo copy] autorelease]]; 

günü

Thread 1:EXC_BAD_ACCESS (code=2, address=0xb7ffffc) 

alıyorum hatadır.

Hata kodu durdurur, ancak hata ayıklayıcısına devam edersem Xcode donar ve kapatır. Bu sorunu nasıl giderebilirim?

+0

nasıl 'userInfo' beyan etmedi

- (void)dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } 
? – Kjuly

+0

'\t \t NSMutableDictionary * userinfo = [NSMutableDictionary dictionaryWithObjectsAndKeys: \t \t \t \t \t \t \t \t \t \t görüntü AsyncImageImageKey, \t \t \t \t \t \t \t \t \t \t URL AsyncImageURLKey, \t \t \t \t \t \t \t \t \t \t nil]; çalışır ama aynı zamanda yeni bir AsyncImagView.m var ve hat bu '[[NSNotificationCenter defaultCenter] postNotificationName oldu' – BigT

cevap

3

aşağıdaki kodu deneyin, sorun olmalıdır:

NSDictionary * userInfo = [NSDictionary dictionaryWithObjectsAndKeys:..., nil]; 
[[NSNotificationCenter defaultCenter] postNotificationName:AsyncImageLoadDidFinish 
                object:target 
                userInfo:userInfo]; 

ya: init olarak

NSDictionary * userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:..., nil]; 
[[NSNotificationCenter defaultCenter] postNotificationName:AsyncImageLoadDidFinish 
                object:target 
                userInfo:userInfo]; 
[userInfo release]; 
+0

: AsyncImageLoadDidFinish \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t object: _target \t \t \t \t \t \t \t \t \t \t \t \t \t \t userinfo:] [[userinfo] sallanmasını kopya]; ' – BigT

+0

@BigT Üzgünüm, Sorunu çözmüş ne said..Have hakkında çok net değilim ?? – Kjuly

+0

Evet var. Bu çizgi çalıştı ama AsyncImageView.m güncelledim ve bu hat yerine oradaydı. Her ikisi de çalışıyor. – BigT

15

kayıt gerekir ve dealloc un kayıt gerekiyor!

-(void)dealloc 
{ 
    [[NSNotificationCenter defaultCenter] removeObserver:self name:AsyncImageLoadDidFinish object:nil]; 

VEYA