2010-09-09 55 views
1

我收到此錯誤「消息發送到解除分配實例0x141dafb0」它從UIBarButtonItem來的時候,它的beeing在應用程序上按下。任何幫助將不勝感激消息發送到解除分配的實例0x141dafb0 iPhone SDK

錯誤:

*** -[PeerConnection performSelector:withObject:withObject:]: message sent to deallocated instance 0x14143ff0 

PeerConnection.h

#import <UIKit/UIKit.h> 
#import <GameKit/GameKit.h> 

@interface PeerConnection : NSObject <GKPeerPickerControllerDelegate, GKSessionDelegate> { 
UIBarButtonItem *StartConnection; 
} 

- (IBAction) StartConnectionAction; 

@property (nonatomic, retain) IBOutlet UIBarButtonItem *StartConnection; 

@end 

PeerConnection.m

#import "PeerConnection.h" 


@implementation PeerConnection 
@synthesize StartConnection; 


- (IBAction) StartConnectionAction { 
NSLog(@"Start Connection to the other IPhones"); 
[StartConnection release]; 
} 

- (void)dealloc { 
[super dealloc]; 
} 

@end 

我已經啓用了殭屍,這是其所有給予我

回答

2

不要釋放您的StartConnection按鈕,直到-dealloc。釋放-StartConnectionAction中的酒吧按鈕項是您的問題 - 之後,用戶界面嘗試使用它的任何內容都將稱爲殭屍。

+0

我做過之前,但它仍然發出同樣的錯誤,但與不同的異常代碼現在它給我「*** - [PeerConnection performSelector:withObject:withObject:]:消息發送到釋放實例0x14159ff0」 – 2010-09-09 13:32:13

+0

這就是發生在您提供給我們的代碼之外的某處。確保你在viewController之前不釋放任何東西,它將使用它deallocs。 – 2010-09-09 14:11:41

0

這可能是由於訪問GC期間已刪除的實例。在使用autorelease的情況下發生錯誤。

ThePlannerAppDelegate *delg = [(ThePlannerAppDelegate *)[[UIApplication sharedApplication] delegate] autorelease]; 

現在,儘管delg指向主窗口委託,但這很有可能是GC將銷燬引用。

我的觀點是安全地使用autorelease。

重要提示:將消息發送到死參考時會發生此錯誤。

+0

將代碼放在代碼塊中。 – 2012-11-27 17:32:28

1

就你而言,你已經發布了StartConnection對象。現在,當調用自動dealloc時,沒有找到引用(因爲已經被刪除),因此你得到了錯誤。

0

我有同樣的錯誤,但在共享方法上使用autorelease的單例,從那裏啓動autorelease並添加它的dealloc,現在所有工作都正常。

0

Old Thread;但是我想我可以補充一下。

如果您的應用程序未使用ARC;使用分析功能查找由於釋放/保留對象而可能出現的所有問題。

快捷方式是command + shift + B

完全有用!

相關問題