【发布时间】:2009-06-08 06:40:55
【问题描述】:
我是 C、Obj-C 和 iPhone 的初学者,我正在尝试掌握很多使用的术语。我希望你们中的一个可以帮助解决我这几天一直在努力解决的问题。
我下面的代码是一种调用包含搜索字段和表格的笔尖的方法。该表是通过搜索为下面的“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];
}
提前致谢!
【问题讨论】:
标签: iphone objective-c cocoa-touch memory-management