2

我正在开发一个类似于PageControlApple 提供的示例的应用程序。我的应用程序从服务器获取数据并将其存储在NSMutableArray本地。然后通过加载单元格nib以网格格式显示该数组。

我的应用程序在擦除过程中在模拟器上运行,但当我尝试在设备上运行它时,我的应用程序崩溃了。

此外,当我在使用它的设备上运行它时,Instruments它执行得很好。

已启用僵尸并出现以下错误。

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

这就是我正在做的事情:

  1. didFinishLaunchingWithOptions我调用两个网络服务时,获取数据并将其存储在本地数组中
  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

1 回答 1

-5

可能是在将发布消息发送给它之前,您的数据数组可能会因任何逻辑错误而被解除分配

使用断点检查它在哪里被释放

于 2012-09-17T13:00:16.407 回答