本文介绍了iOS - “添加”在codeSense中出现自动合成属性的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚创建了一个具有以下属性的iOS类:

I just created an iOS class with the following properties:

@property (nonatomic, strong) NSString* foo;
@property (nonatomic, strong) NSObject* bar;
@property (nonatomic) CGRect fubar;

我没有为这些属性添加任何@synthesize或显式的ivars。然后我进入实现文件并开始创建一个方法如下:

I did not put in any @synthesize or explicit ivars for these properties. I then went into the implementation file and started to create a method as follows:

-(void) add

我将光标留在添加一词的末尾。然后在代码意义上弹出以下方法名称:

I left the cursor at the end of the word "add". The following method names then popped up in code sense:

addBar: (NSSet*) objects
addBarObject: (objectType *) object
addFoo: (NSSet*) objects
addFooObject: (objectType *) object
addFubar: (NSSet*) objects
addFubarObject: (objectType *) object

这些方法是什么?是否有任何文档?

What are these methods? Are there any docs for them?

推荐答案

这是一个类可以实现的访问器方法,以支持可变的键值编码 - 很多关系,
见:

That are accessor methods that a class can implement to support Key-Value Coding for mutable to-many relationships, see Mutable Unordered Accessors in the "Key-Value Coding Programming Guide":

-add< Key>对象: -add< Key>:。必须实现这些方法中的至少一种。这些类似于 NSMutableSet 方法
addObject:

-add<Key>Object: or -add<Key>:. At least one of these methods must be implemented. These are analogous to the NSMutableSet method addObject:.

其他Key-Value编码访问器方法也会发生相同的奇怪自动完成,例如

The same "strange" autocompletion happens for other Key-Value coding accessor methods, for example:

- (void)remove...
- (void)intersect...
- (NSUInteger)countOf...

这篇关于iOS - “添加”在codeSense中出现自动合成属性的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 13:18