我是C,Obj-C和iPhone的初学者,我正在尝试使用很多术语,希望你们能帮助解决问题。现在已经挣扎了几天在iPhone上泄漏内存:(
我的代码是调用一个包含一个搜索字段和一个表的nib的方法,该表从下面为'theList'创建的数组的搜索中填充。使用'仪器',我得到一个泄漏线: NSDictionary * theItem = [NSDictionary dictionaryWithObjectsAndKeys:clientName,@“Name”,clientId,@“Id”,nil];,但我不明白为什么: (
我知道这可能是一个难以回答的问题,但如果有的话可以有任何帮助!
- (void)editClient:(id)sender {
if (pickList == nil) {
pickList = [[PickFromListViewController alloc] initWithNibName:@"PickList" bundle:nil];
}
TimeLogAppDelegate *appDelegate = (TimeLogAppDelegate *)[[UIApplication sharedApplication] delegate];
NSMutableArray *theList = [[NSMutableArray alloc] init];
int i;
for (i=0;i < [appDelegate.clients count];i++) {
Client *thisClient = [appDelegate.clients objectAtIndex:i];
NSString *clientName = [[NSString alloc] initWithString: thisClient.clientsName];
NSNumber *clientId = [[NSNumber alloc] init];
clientId = [NSNumber numberWithInt:thisClient.clientsId];
NSDictionary *theItem = [NSDictionary dictionaryWithObjectsAndKeys:clientName,@"Name",clientId,@"Id",nil];
[theList addObject:theItem];
theItem = nil;
[clientName release];
[clientId release];
}
[pickList createSearchItems:theList :NSLocalizedString(@"Client",nil)];
[theList release];
appDelegate.returningID = [NSNumber numberWithInt: projectsClientsId];
[self.navigationController pushViewController:pickList animated:YES];
}
提前感谢!
谢谢你的时间!我确实按照你的建议使用了它,但改变了代码,认为它可以解决问题。现在它按照你的建议回来了,但是泄漏结果相同。我能否认为问题出在被调用的笔尖之内? – Chris 2009-06-08 07:52:25