English 中文(简体)
预防性财产转让
原标题:Prevent Erroneous Property Assignment

Porting android applications to iphone applications always gives me the following pattern that I accidentally create:

- (void) myFunc:(id)prop {
    self.property = property;
}

而是应当:

- (void) myFunc:(id)prop {
    self.property = prop;
}

这总是导致我的方案突然中断,因为财产已恢复到现有价值,而不是被设定为新的价值,即推进物。 由于汇编抱怨参数掩盖了实例变量的可见度,我不能把准参数的推进物命名为财产。

是否有办法避免这种情况? 没有编辑的警告。 是否有办法使X条码防止这种情况? 我看不出很多情况,即你会把财产设定到其基本情况变数的价值上(也许会触发一种具有约束力的KVO?),但我看不到自己在大多数情况下这样做。

我理解上述法典是合成的,应该用@synthesize来做,但我只是将它作为简单的例子来说明我的观点。

最佳回答

许多人选择用大的强调来标明他们的典型变量。 这将使你能够点名贵国的参数<编码>property,而且你不大可能意外地打上显示。

或者,你可以指定贵参数<代码>新格式,这可能会使其大不相同,难以加以混淆?

问题回答

暂无回答




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签