也许这是解决此问题的错误方法,但它似乎是一种干净且可行的方法,我想知道如何使编译器警告消失?
@interface SomeView : UIView {
NSString *stringOfsomeImportance;
RelatedClass *niftyService;
}
@property (nonatomic, copy) NSString * stringOfnoImportance;
@property (nonatomic, retain) RelatedClass *niftyService;
@implementation
-(void)someMethod;
-(void)otherMethods;
@implementation RelatedClass *pvSomeObj = [[RelatedClass alloc] initWithSender:self];
[self setNiftyService:pvSomeObj];
现在,看看 RelatedClass 的实现......
@interface RelatedClass : NSObject {
id thesender;
@property (nonatomic, retain) id thesender;
@implementation
[thesender otherMethods]; // this generates a compiler warning
// that otherMethods cannot be found
// in SomeView, though it *is* found
// and seems to execute just fine
这似乎是一种有效的方法,所以我想知道为什么会出现警告?有没有办法更好地向编译器“解释”这一点?
如果鼓励这种类型的链接,或者是否有更好的方法来链接两个需要相互通信的相关、相互依赖的类,有人可以分享一下吗?
我不能在 RelatedClass 中静态声明发件人对象(SomeView),因为这似乎会导致递归问题,因为 SomeView 是使用 RelatedClass 作为成员定义的......
有什么建议么?