tags:

views:

13

answers:

1

Hello,

I have a property in my UIView class, something like that:

myView.h

@ interface MyView: UIView {

id refView;

}

@property (nonatomic, retain) id refView;

MyView.m

@synthesis refView;

Then in another class can I set the refView property of MyView something like that:

MyViewController.h

@interface MyViewController: UIViewController {

UIView *myView;

}

@property (nonatomic, retain) IBOutlet UIView *myView;

then in MyViewController.m:

[self.myView setRefView:someValue];

When I do that I get this warning: UIView may not response to '-setRefView:' ...

So, is the above way is right or what's the right way to do it. Any help and explanation would be greatly appreciate it. Thanks.

A: 

You added the refView property to MyView class, not UIView, that's why the compiler complains. If you initialize myView with a MyView instance, this will work, even if there's a warning.

To prevent the compiler from complaining, change

@interface MyViewController: UIViewController {

UIView *myView;

}

to

@interface MyViewController: UIViewController {

MyView *myView;

}
David
Thanks a lot, this really helped ...
mshaaban