在 XCode 4.2 (with LLVM):里
-(void) release {}
会弹出警告
warning: Semantic Issue: Conflicting distributed object modifiers on return type in implementation of 'release'
为了去掉警告 修改如下 -(oneway void) release { }
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%23//apple_ref/doc/uid/10000102i.
参考文档
http://stackoverflow.com/questions/5494981/use-case-of-oneway-void-in-objective-c
http://stackoverflow.com/questions/7379470/singleton-release-method-produces-warning
本文详细解释了在XCode4.2环境中,如何通过使用oneway void来解决Objective-C分布式对象API中的冲突修改警告。oneway用于允许在不同线程或应用间使用Objective-C对象,它告诉系统不必阻塞调用线程直到方法返回。此技术特别适用于分布式对象交互,以避免不必要的线程阻塞。

被折叠的 条评论
为什么被折叠?



