iOS 內(nèi)存泄漏處理

問題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 ];

暫時(shí)未找到解決辦法

問題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)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容