久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

-[Not A Type retain]:消息發(fā)送到已釋放的實例

-[Not A Type retain]: message sent to deallocated instance(-[Not A Type retain]:消息發(fā)送到已釋放的實例)
本文介紹了-[Not A Type retain]:消息發(fā)送到已釋放的實例的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我已將我的應用轉(zhuǎn)換為使用 ARC.

I have converted my app to use ARC.

在我有以下代碼行之前:

Before I had the following line of code:

NSArray *colors = [NSArray arrayWithObjects:startColor, endColor, nil];

由于 ARC 不允許將非 Objective-C 指針類型隱式轉(zhuǎn)換為id",因此我重寫了如下行:

Since the implicit conversion of a non-Objective-C pointer type to 'id' is disallowed with ARC, I rewrote the line like this:

NSArray *colors = [NSArray arrayWithObjects:(__bridge id)startColor, (__bridge id)endColor, nil];

在模擬器上一切正常,但在設備上,應用程序在上述行崩潰并顯示錯誤消息:

Everything works fine on the simulator, however on the device the app crashes on the mentioned line with the error message:

-[Not A Type retain]: message sent to deallocated instance

有什么辦法解決嗎?

推薦答案

這個橋接演員可能不起作用,正如 hatfinch 在 here answer here,因為從 -CGColor 返回的 CGColorRef 在您最后一次引用生成它的 UIColor.我認為這是一個錯誤,基于 this Apple developer forum thread 中的討論,但它是對如何管理這些 CGColorRefs 的生命周期的誤讀.

This bridged cast may not work, as hatfinch describes in his answer here, because the CGColorRef returned from -CGColor may not hang around after your last reference to the UIColor that generates it. I thought this was a bug, based on the discussion in this Apple developer forum thread, but it was a misreading of how to manage the lifetime of these CGColorRefs.

一種可行的方法是使用 UIColor 上的 -CGColor 方法提供的內(nèi)置橋接.而不是像上面那樣將 CGColor 保存到臨時變量中,您應該能夠使用以下內(nèi)容:

One way that this will work is to use the built-in bridging provided by the -CGColor method on UIColor. Rather than saving out your CGColor to a temporary variable as you do above, you should be able to use something like the following:

NSArray *colors = [NSArray arrayWithObjects:(id)[color1 CGColor],
                                            (id)[color2 CGColor], nil];

其中 color1color2 是 UIColor 實例.

with color1 and color2 being UIColor instances.

-CGColor 方法會為您處理橋接,根據(jù) 過渡到 ARC 發(fā)行說明.該文檔目前缺少我上面的轉(zhuǎn)換為 id ,這是編譯它所必需的.

The bridging is taken care of for you by the -CGColor method, according to the "The Compiler Handles CF Objects Returned From Cocoa Methods" section of the Transitioning to ARC Release Notes. The documentation is currently missing the cast to id that I have above, which is required to get this to compile.

我已經(jīng)對此進行了測試,它似乎在我的情況下有效,與 Ben 在上面鏈接的開發(fā)者論壇線程中報告的內(nèi)容相匹配.

I've tested this, and it seems to work in my case, matching what Ben reports in the above-linked Developer Forums thread.

除了上述之外,您還可以顯式保留和釋放從 -CGColor 方法返回的 CGColorRefs,并在您的 NSArray 中橋接它們,就像 hatfinch 顯示的那樣 這里.

In addition to the above, you can explicitly retain and release the CGColorRefs returned from the -CGColor method and bridge them across in your NSArray, again as hatfinch shows here.

這篇關(guān)于-[Not A Type retain]:消息發(fā)送到已釋放的實例的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Using Instruments to test an iOS app without having source code to the application(在沒有應用程序源代碼的情況下使用 Instruments 測試 iOS 應用程序)
KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動運行/壓力測試 iOS 應用程序以找出罕見 UI 錯誤的原因?)
Can#39;t change target membership visibility in Xcode 4.5(無法更改 Xcode 4.5 中的目標成員身份可見性)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態(tài)和動態(tài)單元格中處理單元格選擇)
How to remove Address Bar in Safari in iOS?(如何在 iOS 中刪除 Safari 中的地址欄?)
iOS 5 SDK is gone after upgrade to Xcode 4.5(升級到 Xcode 4.5 后,iOS 5 SDK 消失了)
主站蜘蛛池模板: 在线观看国产视频 | 午夜国产羞羞视频免费网站 | 午夜丰满寂寞少妇精品 | 国产精品99视频 | 国产精品久久久久无码av | 人人干人人玩 | 美女国产精品 | 视频精品一区二区三区 | 天天干狠狠干 | 一区二区在线免费播放 | 超碰精品在线观看 | 久久国产精品久久久久久久久久 | 日本久久www成人免 成人久久久久 | 久久精品国产一区二区三区 | 伊人二区| 欧美另类视频在线 | 欧美激情一区 | 精品不卡 | 亚洲欧洲精品一区 | 欧美视频在线看 | 91精品国产91久久久久久最新 | 一本在线 | 国产精品国产三级国产aⅴ无密码 | 国产午夜精品一区二区三区 | 性网址| 欧美极品在线视频 | 国产成人免费 | 99精品国产一区二区三区 | 成人免费观看视频 | 亚洲播放 | 亚洲国产欧美日韩 | 99精品欧美一区二区蜜桃免费 | 午夜视频在线观看网站 | 欧美成人精品一区二区男人看 | 免费看黄视频网站 | 成人午夜视频在线观看 | 在线观看av网站 | 国产精品国产三级国产aⅴ无密码 | 亚洲午夜小视频 | 中文字幕视频在线看 | 亚洲综合电影 |