Hope someone can help me with this, it has me totally stumped
My application has two view controllers in a tab bar...
//Create two view controllers
UIViewController *vc1 = [[RecordingViewController alloc] init];
UIViewController *vc2 = [[SavedViewController alloc] init];//this is a tableViewController
//Make an array with the two view controllers
NSArray *viewControllers = [NSArray arrayWithObjects:vc1, vc2, nil];
//Release the two view controllers since they are now retained by the array
[vc1 release];
[vc2 release];
//Attach the ViewControllers to the tabBar
[tabBarController setViewControllers:viewControllers];
I then have another object (fileHandler
) which wants to send an object called capture
to vc2
for addition to an NSMutableArray
, so from that class I send...
[vc2 addToCapturesArray:capture];
Of course this does not work and I just get the "vc2 undeclared" message from the compiler. How do I let my fileHandler
class know about the vc2 instance? Thanks in advance for all your help.
Thanks for the help. It all now compiles, however the method in vc2 is not getting called for some reason. The code now looks like this...
@interface Rolling_VideoAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
//Tab bar
UITabBarController *tabBarController;
//Create an ivar so that the app delegate can hold a reference
SavedViewController *_vc2;
} @property (nonatomic, retain) IBOutlet UIWindow *window; //Create a property so we can access vc2 from the outside @property (nonatomic, retain) SavedViewController *vc2;
#import "Rolling_VideoAppDelegate.h"
//Import view controllers
#import "RecordingViewController.h"
#import "SavedViewController.h"
@implementation Rolling_VideoAppDelegate
@synthesize window;
@synthesize vc2 = _vc2;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Create an instance of tabBarView controller
tabBarController = [[UITabBarController alloc]init];
//Create two view controllers
UIViewController *vc1 = [[RecordingViewController alloc] init];
UIViewController *vc2 = [[SavedViewController alloc] init];
self.vc2 = _vc2;
//Make an array with the two view controllers
NSArray *viewControllers = [NSArray arrayWithObjects:vc1, vc2, nil];
//Release the two view controllers since they are now retained by the array
[vc1 release];
[vc2 release];
//Attach the ViewControllers to the tabBar
[tabBarController setViewControllers:viewControllers];
//Place the tabBar on the window
[window addSubview:[tabBarController view]];
[self.window makeKeyAndVisible];
return YES;
}
The file handler looks like this...
Captures *capture = [[Captures alloc]initWithVideoPath:savePath];
NSLog(@"Instance of capture called:\n VideoPath: %@ \n Geo: %@, \n UserNotes: %@", [capture videoPath], [capture location], [capture userNotes]);
// Get a reference to the app delegate, and then access the vc2 property
Rolling_VideoAppDelegate *appDelegate = (Rolling_VideoAppDelegate*)[UIApplication sharedApplication].delegate;
[appDelegate.vc2 addToCapturesArray:capture];
Thanks again for all the help.
Rich
>
starts a blockquote environment; indenting by four spaces starts a code environment. daringfireball.net/projects/markdown/syntax – Jonathan Sterling