three20应用程序崩溃,一些人认为改变后

three20应用程序崩溃,一些人认为改变后

问题描述:

第一,我跟着这个教程:three20 github tutorialthree20应用程序崩溃,一些人认为改变后

我有一个内存管理问题,我认为,它崩溃我的应用程序。

我想,_properties在我的postsModel崩溃我的应用程序。

我第一次启动我的应用程序并将视图更改为我的postsTableViewController工作得很好。我创建了一个TTLauncherView,改回这个viewcontroller崩溃我的应用程序。

现在

这里我postsModel

// .h 
@interface postsModel : TTURLRequestModel { 
    NSMutableArray *_properties; 
} 
@property (nonatomic, readonly)NSMutableArray *properties; 

// .m 
@synthesize properties = _properties; 
- (void)requestDidFinishLoad:(TTURLRequest*)request { 
    TTURLDataResponse* response = request.response; 
    NSString* responseBody = [[NSString alloc] initWithData: response.data encoding: NSUTF8StringEncoding]; 

    NSDictionary *json = [responseBody JSONValue]; 
    TT_RELEASE_SAFELY(responseBody); 

    NSMutableArray *resultSet = [json objectForKey:@"posts"]; 
    TT_RELEASE_SAFELY(_properties); 
    _properties = [NSMutableArray arrayWithArray:resultSet]; 
    TT_RELEASE_SAFELY(resultSet); 

    [super requestDidFinishLoad:request]; 
} 


- (void)dealloc { 
    TT_RELEASE_SAFELY(_properties); 

    [super dealloc]; 
} 

删除我_properties的tt_release的一些代码停止从这个观点来启动程序视图会回来,但再次点击我的TableView崩溃的应用程序,再次崩溃的应用程序。

它有点难以为我写下来,因为它有相当多的代码。我也可以提供我的应用程序作为.zip文件,如果它有帮助,它现在是非常基本的。

谢谢

是的,这个错误是常见的错误。变化:

_properties = [NSMutableArray arrayWithArray:resultSet]; 

要:

_properties = [[NSMutableArray arrayWithArray:resultSet] retain]; 

,或使财产保留和使用:

self.properties = [NSMutableArray arrayWithArray:resultSet]; 
+0

有我的死机问题:( – choise 2010-02-25 22:33:00

+0

好无影响,寻找在其他类似的错误你的代码的一部分然后,这肯定会导致崩溃。 – 2010-02-26 03:45:39

+0

有没有办法找到我的应用程序崩溃的位置?调试器是不是真的有帮助 – choise 2010-02-26 06:35:01