quelqu'un L'espoir peut me aider, il m'a totalement déconcertéEnvoyer objet contrôleur UITableView
Mon application a deux contrôleurs de vue dans une barre d'onglets ...
//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];
Je puis un autre objet (fileHandler
) qui veut envoyer un objet appelé capture
-vc2
pour plus d'un NSMutableArray
, donc de cette classe ... j'envoie
[vc2 addToCapturesArray:capture];
Bien sûr, cela ne fonctionne pas et je reçois simplement le message "vc2 undeclared" du compilateur. Comment puis-je informer ma classe fileHandler
de l'instance vc2? Merci d'avance pour toute votre aide.
Merci pour l'aide. Tout compile maintenant, cependant la méthode dans vc2 n'est pas appelée pour une raison quelconque. Le code ressemble maintenant à ceci ...
@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, conserver) IBOutlet UIWindow * fenêtre; // Créer une propriété pour que nous puissions accéder à vc2 depuis l'extérieur @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;
}
Le gestionnaire de fichiers ressemble à ceci ...
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];
Merci encore pour toute l'aide.
Rich
Y at-il raison que la classe FileHandler ne peut pas être une variable d'instance dans le second contrôleur de vue? –
Juste pour que vous sachiez, '>' commence un environnement blockquote; indenter par quatre espaces démarre un environnement de code. http://daringfireball.net/projects/markdown/syntax –
Toutes mes excuses pour le balisage. – Shadrax