Hello,
I am writing an application for the Apple iPhone / Touch. Everything is going pretty well though one thing I am doing is generating warnings. Not errors but warnings, the applications still builds, installs, and runs. Though these warnings are making me think there must be a more proper way to code the functionality that I am developing.
This is an example of what I am doing and the warnings it generates:
I have a subclassed UIViewController that adds several subviews. In some of these subviews I need the ability to have the subview call methods that are located in the UIViewController object that loaded it.
This is how I am currently doing it:
In the UIViewController's .h file I have something like this:
Code:
#import <UIKit/UIKit.h>
#import "TimedBarView.h"
@interface SomeViewController : UIViewController
{
IBOutlet TimedBarView *timedBarSubView;
}
@property (nonatomic,retain) IBOutlet TimedBarView *timedBarSubView;
- (void)timedBarDone;
In the subclassed UIViewController's .m file I have something like this:
Code:
#import "SomeViewController.h"
@implementation SomeViewController
@synthesize timedBarSubView;
In this same file I have some code like this in the - (void)viewDidLoad method:
Code:
self.timedBarSubView.parent = self;
This code sets a UIViewController pointer called parent that is defined in TimedBarView.h as:
Code:
@interface TimedBarView : UIViewController
{
UIViewController *parent;
}
@property (nonatomic, retain) UIViewController *parent;
- (void)updateTimerBar;
In this same file I have code in the updateTimerBar method that does this:
Code:
if (progress >= 0)
{
[timer invalidate];
[self.view removeFromSuperview];
[parent timedBarDone];
}
The line [parent timedBarDone]; in the above code is what generates the following warning:
'UIViewController' may not respond to '-timedBarDone' (Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments.)
Though, there is a matching method and it does get called and functions as expected. Does anyone have any idea of what is causing this warning and how I can have a subview call its parents methods without generating such a warning?
One example of why it's so critical that the child be able to call methods in the parent object is that this timedBarView object has a button on it that enables the user to have this subview slide off screen (except for a small button that allows it to return into full view). A subview, as far as I can tell, is oblivious as to its geometry within its parent's UIView. Secondly, it is my hope that I can write such a class so that I can create several of these objects to be used throughout my application and possibly make it part of a static library that I could link against to build other applications with. So, with this in mind the object will not know who it's parent is until the code is executed.
I know the parent pointer is not included in the the default variables like self is. I thought the way I approached this made sense and it does work, but this warning has me concerned.
Thanks in advance for reading this post and any advice you can offer.
Nick Powers