Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone three20应用程序在某些视图更改后崩溃_Iphone_Objective C_Cocoa Touch_Three20 - Fatal编程技术网

Iphone three20应用程序在某些视图更改后崩溃

Iphone three20应用程序在某些视图更改后崩溃,iphone,objective-c,cocoa-touch,three20,Iphone,Objective C,Cocoa Touch,Three20,首先,我遵循本教程: 我想我有一个内存管理问题,这会使我的应用程序崩溃 我想,我的postsModel中的\u属性会使我的应用程序崩溃 我第一次启动应用程序并将视图更改为我的postsTableViewController时效果很好。我创建了一个TTLauncherView,更改回该viewcontroller会使我的应用程序崩溃 下面是我的postsModel的一些代码 // .h @interface postsModel : TTURLRequestModel { NSMutab

首先,我遵循本教程:

我想我有一个内存管理问题,这会使我的应用程序崩溃

我想,我的postsModel中的
\u属性
会使我的应用程序崩溃

我第一次启动应用程序并将视图更改为我的
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];
}
删除my_属性的tt_版本会通过从该视图返回Launcher视图停止崩溃应用程序,但再次单击my TableView会再次崩溃应用程序

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


谢谢

是的,这个bug很常见。更改:

_properties = [NSMutableArray arrayWithArray:resultSet];
致:

或使财产保留和使用:

self.properties = [NSMutableArray arrayWithArray:resultSet];

对我的崩溃问题没有影响:(那么,在代码的其他部分寻找类似的错误。这肯定会导致崩溃。没有办法找到我的应用程序崩溃的位置吗?调试器没有真正的帮助吗?调试器中看到了什么?如果启用NSZombieEnabled怎么办?谢谢!没有保留或使用我的属性对象的setter方法是错误的。)通过修复这个问题,我很容易发现我释放一个已经释放的对象造成的另一个内存泄漏。现在它工作得很好。
self.properties = [NSMutableArray arrayWithArray:resultSet];