0

I am a new programmer of Iphone Application. I work dynamically not use nib files. I want to pass values from one view controller to another.

in firstView.m

these two values

cell.textLabel.text
cell.detailTextLabel.text 

i want to pass in the TabBarSearchThirdView init method..

TabBarSearchThirdView *thirdView=[[TabBarSearchThirdView alloc]init];
[myView addSubview:thirdView.view];

in TabBarSearchThirdView.m file.

-(id)init
{
firstVariable=..........
secondVariable=..........
}

Hope you understood my question. Give me little code or suggestions if possible and give me a link of easy and good table view tutorial. If possible

Thanks in advance

Nitish
  • 13,845
  • 28
  • 135
  • 263
GauravBoss
  • 140
  • 2
  • 4
  • 13

3 Answers3

3

You should declare a new init method like this one

- (id)initWithText:(NSString *)aText andDetail:(NSString *)aDetail{
    self = [super init];

    if(self){
        firstVariable  = aText;
        secondVariable = aDetail;
    }

    return self;
}
Luca Bernardi
  • 4,191
  • 2
  • 31
  • 39
  • @Luca..thanks....your code work fine... only this warning comes... can you suggest me..why warning come------->(Messages without a matching method signature – GauravBoss Nov 04 '11 at 11:17
0

For passing data between viewcontrollers my answer at the below link will help. How to pass a tableview cell value to another page(uiviewcontroller)?

Community
  • 1
  • 1
sElanthiraiyan
  • 6,000
  • 1
  • 31
  • 38
0

for passing values from 1 controller to another controller, you have to define 2 variables in AppDelegate class, with property and synthesis . example NSstring *firstVariable and NSString *secondVariable and mention its property and synthesis.

and after your code TabBarSearchThirdView *thirdView=[[TabBarSearchThirdView alloc]init];

 MyAppnameDelegate AppDel = (MyAppnameAppDelegate*)[[UIApplication sharedApplication]delegate];

//MyAppnameDelegate is your appdelegete class, so change it by your appDelegate class

AppDel.firstVariable =cell.textLabel.text;
AppDel. secondVariable = cell.detailTextLabel.text;
[myView addSubview:thirdView.view];

process to access values in Third class is In viewDidLoad{ MyAppnameDelegate AppDel = (MyAppnameAppDelegate*)[[UIApplication sharedApplication]delegate]; //MyAppnameDelegate is your appdelegete class, so change it by your appDelegate class

nsstring *accessfirstVariable     =.AppDel.firstVariable
nsstring  *accesssecondVariable  =AppDel. secondVariable
}

and use this where ever u like… cheers

vijay gupta
  • 242
  • 1
  • 12