pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    1. <tfoot id='oqbPn'></tfoot>
      <legend id='oqbPn'><style id='oqbPn'><dir id='oqbPn'><q id='oqbPn'></q></dir></style></legend>

      <small id='oqbPn'></small><noframes id='oqbPn'>

        <bdo id='oqbPn'></bdo><ul id='oqbPn'></ul>
    2. <i id='oqbPn'><tr id='oqbPn'><dt id='oqbPn'><q id='oqbPn'><span id='oqbPn'><b id='oqbPn'><form id='oqbPn'><ins id='oqbPn'></ins><ul id='oqbPn'></ul><sub id='oqbPn'></sub></form><legend id='oqbPn'></legend><bdo id='oqbPn'><pre id='oqbPn'><center id='oqbPn'></center></pre></bdo></b><th id='oqbPn'></th></span></q></dt></tr></i><div class="bbhzrfh" id='oqbPn'><tfoot id='oqbPn'></tfoot><dl id='oqbPn'><fieldset id='oqbPn'></fieldset></dl></div>

        ARC,塊中的 ivars 和通過捕獲的自我的參考周期

        ARC, ivars in Blocks and Reference Cycles via Captured Self(ARC,塊中的 ivars 和通過捕獲的自我的參考周期)
        <i id='xmdOh'><tr id='xmdOh'><dt id='xmdOh'><q id='xmdOh'><span id='xmdOh'><b id='xmdOh'><form id='xmdOh'><ins id='xmdOh'></ins><ul id='xmdOh'></ul><sub id='xmdOh'></sub></form><legend id='xmdOh'></legend><bdo id='xmdOh'><pre id='xmdOh'><center id='xmdOh'></center></pre></bdo></b><th id='xmdOh'></th></span></q></dt></tr></i><div class="t5vxpl5" id='xmdOh'><tfoot id='xmdOh'></tfoot><dl id='xmdOh'><fieldset id='xmdOh'></fieldset></dl></div>

      1. <small id='xmdOh'></small><noframes id='xmdOh'>

                  <bdo id='xmdOh'></bdo><ul id='xmdOh'></ul>
                  <legend id='xmdOh'><style id='xmdOh'><dir id='xmdOh'><q id='xmdOh'></q></dir></style></legend>

                  <tfoot id='xmdOh'></tfoot>
                    <tbody id='xmdOh'></tbody>

                  本文介紹了ARC,塊中的 ivars 和通過捕獲的自我的參考周期的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我在純 iOS5/ARC 環境中工作,所以我可以根據需要使用 __weak 引用.在許多情況下,我確實在塊中引用了 ivars,最值得注意的是,移動視圖的動畫塊,例如,我的視圖控制器類的屬性.

                  I’m working in a pure iOS5/ARC environment, so I can use __weak references as needed. I do reference ivars in a block in many situations, most notably, animation blocks that move views around, which are properties of say, my view controller class.

                  在一個塊中最簡單的 ivars 使用中,我是在創建一個引用循環嗎?我是否需要使用 __weak self/strong self 技術每次我編寫一個操作包含對象的實例變量的塊?

                  In the most trivial use of ivars in a block, am I creating a reference cycle? Do I need to use the __weak self / strong self technique everytime I write a block that manipulates instance variables of the containing object?

                  我一直在重新觀看 2011 年 WWDC 會議 #322(Objective-C 深度改進),以了解從時間索引 25:03 開始??的 3 分鐘片段通過捕獲的自我進行參考循環"的細微差別.對我來說,這意味著塊中任何 ivars 的使用都應該通過該部分中描述的弱自我/強自我設置來保護.

                  I’ve been re-watching the 2011 WWDC Session #322 (Objective-C Advancements in Depth) to understand the nuances regarding the 3 minute segment starting at time index 25:03 about "Reference Cycle Via Captured Self". To me, this implies any usage of ivars in a block should be safeguarded with the weak self / strong self setup as described in that segment.

                  以下視圖控制器上的示例方法是我所做的典型動畫.

                  The sample method below on a view controller, is typical of animations I do.

                  在openIris塊中,像我一樣引用ivars_topView"和_bottomView"是不是錯了?

                  In the openIris block, is it wrong to reference ivars "_topView" and "_bottomView" as I have?

                  我是否應該始終在塊之前設置對 self 的 __weak 引用,然后在塊內對之前設置的弱引用設置強引用,然后通過塊內的強引用訪問 ivars?

                  Should I always setup a __weak reference to self before the block, then a strong reference inside the block to the weak reference just setup prior, and then access the ivars through that strong reference within my block?

                  從 WWDC 會議中,我了解到在塊中引用 ivars 實際上是在創建對這些 ivars 所依賴的隱含自我的引用.

                  From the WWDC session, I understand that referencing ivars in a block is really creating a reference to the implied self that these ivars hang off of.

                  對我來說,這意味著真的沒有任何簡單或瑣碎的情況可以在沒有弱/強舞蹈以確保沒有循環的情況下訪問塊中的 ivars 是正確的.或者我是否閱讀了很多不適用于簡單案例的極端案例,例如我的示例?

                  To me, this implies that there really isn’t any simple or trivial case where it is correct to access ivars in a block without the weak/strong dance to ensure no cycles. Or am I reading to much into a corner case that doesn’t apply to simple cases, such as my example?

                  - (void)openIrisAnimated:(BOOL)animated
                  {
                      if (_isIrisOpened) {
                          NSLog(@"Asked to open an already open iris.");
                          return; // Bail
                      }
                  
                      // Put the common work into a block.
                      // Note: "_topView" and "_bottomView" are the backing ivars of 
                      // properties "topView" and "bottomView"
                      void (^openIris)() = ^{
                          _topView.frame     = CGRectMake(....);        
                          _bottomView.frame  = CGRectMake(....);
                      };
                  
                      // Now do the actual opening of the iris, whether animated or not:
                      if (animated) {
                          [UIView animateWithDuration:0.70f 
                                           animations:^{
                                               openIris();
                                           }];
                      }
                      else {
                          openIris();
                      }
                  
                      _irisOpened = YES; // Because we have now just opened it
                  }
                  

                  以下是我使用 Session #322 的指導重寫 openIris 塊的方法,但我只是想知道我的所有類似塊是否都需要這種弱/強參考舞蹈來確保正確性和穩定性:

                  Here’s how I’d re-write the openIris block piece using the guidance from Session #322, but I’m just wondering if all my similar blocks require this weak/strong reference dance to ensure correctness and stability:

                  __weak MyClass *weakSelf = self;
                  
                  
                  void (^openIris)() = ^{
                       MyClass *strongSelf = weakSelf;
                  
                       if (strongSelf) {        
                          strongSelf.topView.frame     = CGRectMake(....);
                          strongSelf.bottomView.frame  = CGRectMake(....);
                       }
                  };
                  

                  這真的有必要嗎?

                  推薦答案

                  這里只有一個循環,如果 self 然后繼續持有對塊的引用(或自己擁有的東西).如果不是,你最好去,因為塊的生命周期不是由它保留的 self 決定的.

                  There is only a cycle here if self then goes on to hold a reference to the block (or something owned by self). If not you're good to go as the lifetime of the block is not dictated by the self it retained.

                  因此,在您的特定示例中,您似乎很清楚.動畫塊不需要參與弱/強自舞.

                  So in your particular example, you seem to be in the clear. Animation blocks don't need to participate in the weak/strong self dance.

                  這篇關于ARC,塊中的 ivars 和通過捕獲的自我的參考周期的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  How to animate a UIImageview to display fullscreen by tapping on it?(如何通過點擊動畫 UIImageview 以顯示全屏?)
                  To stop segue and show alert(停止 segue 并顯示警報)
                  iOS 5 storyboard, programmatically determine path(iOS 5 故事板,以編程方式確定路徑)
                  Icon already includes gloss effects(圖標已經包含光澤效果)
                  How does UIEdgeInsetsMake work?(UIEdgeInsetsMake 是如何工作的?)
                  UIProgressView and Custom Track and Progress Images (iOS 5 properties)(UIProgressView 和自定義跟蹤和進度圖像(iOS 5 屬性))
                      <tbody id='wTnNM'></tbody>

                    1. <legend id='wTnNM'><style id='wTnNM'><dir id='wTnNM'><q id='wTnNM'></q></dir></style></legend>
                        • <bdo id='wTnNM'></bdo><ul id='wTnNM'></ul>

                          <small id='wTnNM'></small><noframes id='wTnNM'>

                          <tfoot id='wTnNM'></tfoot>

                          • <i id='wTnNM'><tr id='wTnNM'><dt id='wTnNM'><q id='wTnNM'><span id='wTnNM'><b id='wTnNM'><form id='wTnNM'><ins id='wTnNM'></ins><ul id='wTnNM'></ul><sub id='wTnNM'></sub></form><legend id='wTnNM'></legend><bdo id='wTnNM'><pre id='wTnNM'><center id='wTnNM'></center></pre></bdo></b><th id='wTnNM'></th></span></q></dt></tr></i><div class="5v7dhnr" id='wTnNM'><tfoot id='wTnNM'></tfoot><dl id='wTnNM'><fieldset id='wTnNM'></fieldset></dl></div>
                            主站蜘蛛池模板: 河南膏药贴牌-膏药代加工-膏药oem厂家-洛阳今世康医药科技有限公司 | 污水处理设备维修_污水处理工程改造_机械格栅_过滤设备_气浮设备_刮吸泥机_污泥浓缩罐_污水处理设备_污水处理工程-北京龙泉新禹科技有限公司 | 大巴租车平台承接包车,通勤班车,巴士租赁业务 - 鸿鸣巴士 | 云南成考网_云南成人高考报名网 粤丰硕水性环氧地坪漆-防静电自流平厂家-环保地坪涂料代理 | 亿立分板机_曲线_锯片式_走刀_在线式全自动_铣刀_在线V槽分板机-杭州亿协智能装备有限公司 | PE拉伸缠绕膜,拉伸缠绕膜厂家,纳米缠绕膜-山东凯祥包装 | 点焊机-缝焊机-闪光对焊机-电阻焊设备生产厂家-上海骏腾发智能设备有限公司 | 定制/定做衬衫厂家/公司-衬衫订做/订制价格/费用-北京圣达信 | 一体化预制泵站-一体化提升泵站-一体化泵站厂家-山东康威环保 | 滚筒烘干机_转筒烘干机_滚筒干燥机_转筒干燥机_回转烘干机_回转干燥机-设备生产厂家 | BAUER减速机|ROSSI-MERSEN熔断器-APTECH调压阀-上海爱泽工业设备有限公司 | 变色龙PPT-国内原创PPT模板交易平台 - PPT贰零 - 西安聚讯网络科技有限公司 | 房在线-免费房产管理系统软件-二手房中介房屋房源管理系统软件 | 艺术涂料_进口艺术涂料_艺术涂料加盟_艺术涂料十大品牌 -英国蒙太奇艺术涂料 | BOE画框屏-触摸一体机-触控查询一体机-触摸屏一体机价格-厂家直销-触发电子 | 酒水灌装机-白酒灌装机-酒精果酒酱油醋灌装设备_青州惠联灌装机械 | 坏男孩影院-提供最新电影_动漫_综艺_电视剧_迅雷免费电影最新观看 | 京马网,京马建站,网站定制,营销型网站建设,东莞建站,东莞网站建设-首页-京马网 | 海南在线 海南一家 | 美国PARKER齿轮泵,美国PARKER柱塞泵,美国PARKER叶片泵,美国PARKER电磁阀,美国PARKER比例阀-上海维特锐实业发展有限公司二部 | 耐热钢-耐磨钢-山东聚金合金钢铸造有限公司| 螺纹三通快插接头-弯通快插接头-宁波舜驰气动科技有限公司 | 27PR跨境电商导航 | 专注外贸跨境电商| 千淘酒店差旅平台-中国第一家针对TMC行业的酒店资源供应平台 | 神超官网_焊接圆锯片_高速钢锯片_硬质合金锯片_浙江神超锯业制造有限公司 | 石家庄小程序开发_小程序开发公司_APP开发_网站制作-石家庄乘航网络科技有限公司 | 1000帧高速摄像机|工业高速相机厂家|科天健光电技术 | 高光谱相机-近红外高光谱相机厂家-高光谱成像仪-SINESPEC 赛斯拜克 | 实体店商新零售|微赢|波后|波后合作|微赢集团 | 胶辊硫化罐_胶鞋硫化罐_硫化罐厂家-山东鑫泰鑫智能装备有限公司 意大利Frascold/富士豪压缩机_富士豪半封闭压缩机_富士豪活塞压缩机_富士豪螺杆压缩机 | 自动焊锡机_点胶机_螺丝机-锐驰机器人 | 电车线(用于供电给电车的输电线路)-百科 | 5L旋转蒸发器-20L-50L旋转蒸发器-上海越众仪器设备有限公司 | 天津次氯酸钠酸钙溶液-天津氢氧化钠厂家-天津市辅仁化工有限公司 | GEDORE扭力螺丝刀-GORDON防静电刷-CHEMTRONICS吸锡线-上海卓君电子有限公司 | 波纹补偿器_不锈钢波纹补偿器_巩义市润达管道设备制造有限公司 | 新能源汽车电机定转子合装机 - 电机维修设备 - 睿望达 | 风信子发稿-专注为企业提供全球新闻稿发布服务 | 滁州高低温冲击试验箱厂家_安徽高低温试验箱价格|安徽希尔伯特 | 天津货架厂_穿梭车货架_重型仓储货架_阁楼货架定制-天津钢力仓储货架生产厂家_天津钢力智能仓储装备 | 环氧乙烷灭菌器_压力蒸汽灭菌器_低温等离子过氧化氢灭菌器 _低温蒸汽甲醛灭菌器_清洗工作站_医用干燥柜_灭菌耗材-环氧乙烷灭菌器_脉动真空压力蒸汽灭菌器_低温等离子灭菌设备_河南省三强医疗器械有限责任公司 |