天天看點

最近遇到的一些問題

記一下

1  -(void)release  警報 應該使用-(void oneway)方法  

In my singleton release method, I have it doing nothing:-(void) release {  //A whole lot of nothing.}But it produces this warning:Warning: Conflicting distributed object modifiers on return type in implementation of 'release'I googled and saw others have the same error, but no explanation of the warning. Anyone know what the warning is about?You need to declare it oneway.-(oneway void) release {}oneway is a keyword used with distributed objects to indicate that the call can be made asynchronously. Since the NSObject header uses it when it declares the release method, you must also use it. It won't affect your program unless you use distributed objects, but it will satisfy the compiler.In NSObject.h, the definition of the release method returns a oneway void.The oneway keyword is used for distributed objects.Since Xcode4.2 and LLVM, checkings are more strong and if it was accepted by previous versions of Xcode or by gcc, you now need to add this oneway keyword so that the LLVM compiler stops warning about this.-(oneway void) release {/* do nothing */}This won't have any incident on your code.oneway is used with the distributed objects API, which allows use of objective-c objects between different threads or applications. It tells the system that it should not block the calling thread until the method returns. Without it, the caller will block, even though the method's return type is void. Obviously, it is never used with anything other than void, as doing so would mean the method returns something, but the caller doesn't get it.For more on distributed objects, seehttp://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DistrObjects/DistrObjects.html#//apple_ref/doc/uid/10000102i