iOS 内存泄漏处理

问题1:loadNibNamed

static NSString *cellId = @"AboutTableViewCell";
    AboutTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if(!cell)
    {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"AboutTableViewCell" owner:self options:nil] lastObject];
    }

原因:I suspect that your leak may be coming from the outlets in the nib. Note this phrase in the docs on loadNibNamed::
To establish outlet connections, this method uses the setValue:forKey: method, which may cause the object in the outlet to be retained automatically.
In other words, loadNibNamed sometimes imposes an extra retain because of the odd way key-value-coding works.

However, that is speculation, and there's no need for it, because there's no need for you to call loadNibNamed: in the first place!

You're using a custom UITableViewCell subclass, designed in a nib? Then why not do this the normal way? Make a nib containing one top-level object: the cell. Design the cell in the nib, set its class, hook up its outlets etc. In your code, call registerNib:forCellReuseIdentifier: on the table view, to tell the table view about your nib. When you later call dequeueReusableCellWithIdentifier:, if there are no free cells in the reuse pile, the table view will load your nib and hand you cell. No muss, no fuss.

问题2:imageWithRenderingMode

tabBarItem1.selectedImage = [[UIImage imageNamed:@"img_wifi_hl"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];

暂时未找到解决办法

问题3:id bridge

- (id)fetchSSIDInfo

{

    NSArray *ifs = CFBridgingRelease(CNCopySupportedInterfaces());
    id info = nil;
    for (NSString *ifnam in ifs) {
        info = CFBridgingRelease(CNCopyCurrentNetworkInfo((__bridge CFStringRef)ifnam));
        if (info && [info count]) {
            break;
        }
    }
    return info;
}

CFBridgingRelease 替换掉原来的(id bridge)

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容