2010-02-25 29 views
0

第一,我跟着這個教程: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文件,如果它有幫助,它現在是非常基本的。

謝謝

回答

2

是的,這個錯誤是常見的錯誤。變化:

_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