Objective-C in,out,inout,byref,byval,..等.这些是什么? [英] Objective-C in,out,inout,byref,byval, .. and so on. What are they?
问题描述
我在阅读@encoding
的Objective-C手册时发现了一些陌生的东西.
I discovered something unfamiliar while reading Objective-C manual for @encoding
.
Table 6-2 Objective-C method encodings
Code Meaning
r const
n in
N inout
o out
O bycopy
R byref
V oneway
我唯一知道的是oneway
.其他是什么?
The only thing I know is oneway
. What are the others?
推荐答案
这些是分布式对象使用的方法参数和返回值的注释.我之所以说是,是因为显然苹果的文档中再也没有这些迹象了. "Objective-C编程语言"文档中曾经有一个远程消息传递"部分,但分布式对象编程主题"文档中仍然引用了该部分.
Those are annotations for method parameters and return values which were used by Distributed Objects. I say were because apparently there’s no sign of them in Apple’s documentation any longer. There used to be a Remote Messaging section in The Objective-C Programming Language document, which is still referenced by the Distributed Objects Programming Topics document.
- 输入:参数仅是输入参数,以后将不再引用
- 输出:参数仅是输出参数,用于通过引用返回值
- inout:参数既是输入参数又是输出参数
- const :(指针)参数是常量
- bycopy:,而不是使用代理/
NSDistantObject
,而是传递或返回对象的副本 - byref :使用代理对象(默认)
- in: argument is an input argument only and won’t be referenced later
- out: argument is an output argument only, used to return a value by reference
- inout: argument is both an input and output argument
- const: the (pointer) argument is constant
- bycopy: instead of using a proxy/
NSDistantObject
, pass or return a copy of the object - byref: use a proxy object (default)
这篇关于Objective-C in,out,inout,byref,byval,..等.这些是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!