【发布时间】:2011-12-26 08:46:22
【问题描述】:
成功切换到视图后,我的应用程序在模拟器中终止。我确信这很简单,这是终止应用程序的视图中的 .m 文件。也许有些东西没有释放。它不会在控制台中抛出错误,页面加载,等待几秒钟,然后终止并在调试器中抛出 mach_msg_trap。如果我点击播放按钮,它将继续。
@implementation ProspectViewController
@synthesize jsonArray;
- (void)viewDidLoad {
[super viewDidLoad];
NSURL *jsonURL = [NSURLURLWithString:@"https://www.mysite.php"];
NSString *jsonData = [[NSString alloc] initWithContentsOfURL:jsonURL];
self.jsonArray = [jsonData JSONValue];
[jsonURL release];
[jsonData release];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [jsonArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSDictionary *infoDictionary = [self.jsonArray objectAtIndex:indexPath.row];
static NSString *Prospects = @"agencyname";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Prospects];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:Prospects] autorelease];
}
// setting the text
cell.text = [infoDictionary objectForKey:@"agencyname"];
self.navigationItem.title = @"Prospects";
// Set up the cell
return cell;
}
【问题讨论】:
-
ir 应该是由于这些陈述中的一个(或两个)[agencyName release]; [lblText 发布];
-
放置 [super viewDidLoad];在方法的开头。
-
在开头放置一个超级 viewDidLoad 没有帮助。它在 ret 下的调试器中抛出了一个 mach msg 陷阱。
标签: objective-c cocoa-touch ios4 iphone-sdk-3.0