2012-09-17 155 views
2

我正在開發類似於Apple提供的樣本PageControl的應用程序。 我的應用程序從服務器獲取數據並將其存儲在本地的NSMutableArray中。 然後通過加載單元格筆尖以網格格式顯示該數組。*** - [__ NSArrayM發佈]:發送到已釋放實例的消息

我的應用程序在模擬器上運行時有一些滯後,但當我嘗試在設備上運行它時,我的應用程序崩潰。

另外,當我在設備上使用Instruments運行它時,它執行得很好。

已啓用殭屍並出現以下錯誤。

*** -[__NSArrayM release]: message sent to deallocated instance 0x18aef0 

這是我在做什麼:

  1. didFinishLaunchingWithOptions我調用兩個Web服務,獲取數據 並將其存儲在本地陣列
  2. 推在其中生成的頁面視圖控制器

嘗試解決此問題。


這是我的代碼。

 


    //**AppDelegate.h** 
    @interface TumBhiAppDelegate : UIResponder { 
    NSMutableArray *arrDetailsByCategory; 
    } 
    @property (nonatomic, retain) IBOutlet NSMutableArray *arrDetailsByCategory;  
    -(IBAction)doneProcessing:(id)sender; 
    @end 

    //**AppDelegate.m** 
    #import "AppDelegate.h" 
    #import "Server.h" 

    @implementation AppDelegate 
    @synthesize arrDetailsByCategory; 
    //Once processing is done push the view 
    -(IBAction)doneProcessing:(id)sender 
    {  
    BaseContentViewController *baseController = [[BaseContentViewController alloc] initWithNibName:@"BaseContentViewController" bundle:nil];  
    [self.navigationController pushViewController:baseController animated:YES];  
    [baseController release]; 
    } 

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
    { 
    arrDetailsByCategory = [[NSMutableArray alloc] init]; 
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 
    // Override point for customization after application launch. 
    self.viewController = [[TumBhiViewController alloc] initWithNibName:@"TumBhiViewController" bundle:nil]; 

    self.navigationController = [[UINavigationController alloc]initWithRootViewController:self.viewController]; 
    [self.navigationController setNavigationBarHidden:YES]; 

    self.window.rootViewController = self.navigationController; 
    [self.window makeKeyAndVisible]; 
    //getDetails is called 5-6 time 
    //arrDetailsByCategory is populated accordingly 
    [Server getDetails:@"ABC"]; 
    [self doneProcessing:nil]; 
    return YES; 
    } 
    @end 

    //**Server.h** 
    @interface ServerCommunication : NSObject{ 
    } 
    -(BOOL)getDetails:(NSString *)str 
    @end 

    //**Server.m** 
    #import "Server.h" 
    #import "AppDelegate.h" 
    @implementation ServerCommunication 

    -(BOOL)getDetails:(NSString *)str 
    { 
    NSMutableArray *arrFinal = [NSMutableArray array]; 
    //call web-service populate arrFinal 
    [[[AppDelegate GetAppDelegate] arrDetailsByCategory] addObjectsFromArray:arrFinal]; 
    } 
    @end 

 

調試消息

*** -[__NSArrayM release]: message sent to deallocated instance 0x7aa0870 
[Switching to process 636 thread 0x15903] 
[Switching to process 636 thread 0x15903] 
sharedlibrary apply-load-rules all 
(gdb) 

堆棧信息:

0x01920db0 <+0096> testb $0x1,(%eax) 
0x01920db3 <+0099> je  0x1920ded <___forwarding___+157> 
0x01920db5 <+0101> mov %edi,0x4(%esp) 
0x01920db9 <+0105> movl $0x0,0x18(%esp) 
0x01920dc1 <+0113> movl $0x0,0x14(%esp) 
0x01920dc9 <+0121> movl $0x0,0x10(%esp) 
0x01920dd1 <+0129> movl $0x0,0xc(%esp) 
0x01920dd9 <+0137> movl $0x0,0x8(%esp) 
0x01920de1 <+0145> movl $0x15,(%esp) 
0x01920de8 <+0152> call 0x198ec10 <__CFRecordAllocationEvent> 
0x01920ded <+0157> mov -0x10(%ebp),%eax 
0x01920df0 <+0160> mov %eax,(%esp) 
0x01920df3 <+0163> call 0x19fcbf6 <dyld_stub_sel_getName> 
0x01920df8 <+0168> mov %edi,0x10(%esp) 
0x01920dfc <+0172> mov %eax,0xc(%esp) 
0x01920e00 <+0176> add $0xa,%esi 
0x01920e03 <+0179> mov %esi,0x8(%esp) 
0x01920e07 <+0183> lea 0x12e6aa(%ebx),%eax 
0x01920e0d <+0189> mov %eax,0x4(%esp) 
0x01920e11 <+0193> movl $0x3,(%esp) 
0x01920e18 <+0200> call 0x196bad0 <CFLog> 
0x01920e1d <+0205> int3 
0x01920e1e <+0206> call 0x19fc8b4 <dyld_stub_getpid> //**Dies here with Thread 5** 
0x01920e23 <+0211> mov %eax,(%esp) 
0x01920e26 <+0214> movl $0x9,0x4(%esp) 
0x01920e2e <+0222> call 0x19fc908 <dyld_stub_kill> 
0x01920e33 <+0227> xor %edi,%edi 
0x01920e35 <+0229> jmp 0x192112e <___forwarding___+990> 
0x01920e3a <+0234> lea 0xed29f(%ebx),%eax 
0x01920e40 <+0240> mov %eax,0x4(%esp) 
0x01920e44 <+0244> mov %esi,(%esp) 
0x01920e47 <+0247> call 0x19fcc56 <dyld_stub_strcmp> 
0x01920e4c <+0252> test %eax,%eax 
0x01920e4e <+0254> mov %edi,%eax 
0x01920e50 <+0256> mov %eax,%edi 
0x01920e52 <+0258> mov %eax,-0x14(%ebp) 
0x01920e55 <+0261> jne 0x1920e63 <___forwarding___+275> 
0x01920e57 <+0263> mov 0x130e5a(%ebx),%eax 
0x01920e5d <+0269> mov -0x14(%ebp),%ecx 
0x01920e60 <+0272> mov (%ecx,%eax,1),%edi 
0x01920e63 <+0275> mov %edi,(%esp) 
0x01920e66 <+0278> call 0x19fcad6 <dyld_stub_object_getClass> 
0x01920e6b <+0283> mov 0x1255ee(%ebx),%ecx 
+4

顯示你的代碼,沒有它我們不能幫你 –

+0

請給我們一個堆棧跟蹤。 – jrtc27

+0

提供堆棧跟蹤和調試器消息。謝謝。 – Sumit

回答

-5

可能是你的數據陣列可以由任何邏輯錯誤的手段得到解除分配之前被髮送到釋放消息它

使用斷點檢查它被拿回去的地方

+2

從不發送「超級」 –

相關問題