views:

18

answers:

1

my problem is quite simple, but as a beginner, I'm lost :D

I have to view controller :

view one call view 2 like this :

self.FacebookTypeRequest =@"favoris"; 
FaceBookViewController *viewcontrol = [[FaceBookViewController alloc]initWithNibName:@"FaceBookViewController"  bundle:[NSBundle mainBundle]];
viewcontrol.title = @"FaceBook";
[self.navigationController pushViewController:viewcontrol animated:YES];
[viewcontrol release];

How can i send my string facebookTypeRequest to my view controller 2 ?

Thanks for your help

+2  A: 

Hi,

Make a property on your second view controller (FaceBookViewController) like this in the .h file :

@interface FaceBookViewController {
    ...
    NSString *facebookTypeRequest;
    ...
}

@property (nonatomic, copy) NSString *facebookTypeRequest;

and in the .m file put

@implementation FaceBookViewController

    @synthesize facebookTypeReqeust;

and remember to put in your dealloc method

- (void) dealloc {
    [facebookTypeRequest release];
    // release other properties here as well
    [super dealloc];
}

Then, you can just set it like this :

self.FacebookTypeRequest = @"favoris";
FaceBookViewController *viewcontrol = [[FaceBookViewController alloc] initWithNibName:@"FaceBookViewController" bundle:nil];
viewcontrol.title = @"FaceBook";
viewcontrol.facebookTypeRequest = self.FacebookTypeRequest; //!< This is the line :)
[self.navigationController pushViewController:viewcontrol animated:YES];
[viewcontrol release];

Now, inside your FaceBookViewController you have the facebookTypeRequest.

Hope that helps.

NB It's generally bad practice to use captial letters to start the name of a property i.e. self.FaceboookTypeReqeust should really be self.facebookTypeRequest.

deanWombourne
Ok Thanks to youI will try this immediatly
Toma
That's work,Thank you, I understand know how to do that
Toma
No problem. If this answer was correct, feel free to accept it ;)
deanWombourne