小编Chr*_*ris的帖子

iPhone上的内存泄漏:(

我是C,Obj-C和iPhone的初学者,我正在尝试使用大量的术语.我希望你们中的一个能帮助解决我几天来一直在努力解决的问题.

我下面的代码是一个调用包含搜索字段和表的笔尖的方法.该表是通过搜索为下面的'theList'创建的数组来填充的.使用'Instruments',我得到了一个Leak: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];
    } …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch memory-management objective-c

1
推荐指数
1
解决办法
1926
查看次数