首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

xcdoe4.2中,通过ARC来编译,总会遇到一些有关问题,比如原先使用c语言模块

2012-08-22 
xcdoe4.2中,通过ARC来编译,总会遇到一些问题,比如原先使用c语言模块很多时候,在使用Automatic Reference C

xcdoe4.2中,通过ARC来编译,总会遇到一些问题,比如原先使用c语言模块

很多时候,在使用Automatic Reference Counting的是时候,会提示一些很陌生的的错误提示,特别是使用conver to arc后,

?

比如bridged cast?

给你的c代码上面加个_bridged。

?

这里面有个详细的描述,

?

A?bridged cast?is a C-style cast annotated with one of three keywords:

  • (__bridge T) op?casts the operand to the destination type?T. If?T?is a retainable object pointer type, then?op?must have a non-retainable pointer type. If?T?is a non-retainable pointer type, then?op?must have a retainable object pointer type. Otherwise the cast is ill-formed. There is no transfer of ownership, and ARC inserts no retain operations.
  • (__bridge_retained T) op?casts the operand, which must have retainable object pointer type, to the destination type, which must be a non-retainable pointer type. ARC retains the value, subject to the usual optimizations on local values, and the recipient is responsible for balancing that +1.
  • (__bridge_transfer T) op?casts the operand, which must have non-retainable pointer type, to the destination type, which must be a retainable object pointer type. ARC will release the value at the end of the enclosing full-expression, subject to the usual optimizations on local values.

    These casts are required in order to transfer objects in and out of ARC control; see the rationale in the section on?conversion of retainable object pointers.

    Using a?__bridge_retained?or?__bridge_transfer?cast purely to convince ARC to emit an unbalanced retain or release, respectively, is poor form.

    ?

    ?

    其实,你在apple llvm 的提示下面应该就能看到一些消息的描述,主要是说retain,这里面的bridge有unretained 和retained两种,说到这里面大家应该知道retain的含义了。

    ?

    ?

    先写到这。

    ?

    其实在这里面,跟多的是一些警告,让我决定很烦。

    比如隐式转换,和显示转换。

热点排行