Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

iphonejudy

macrumors 6502
Original poster
Sep 12, 2008
301
1
Hi,


I need to display feeds based on the button,

I have two buttons called next and previous.


if i click next button , i need to display some feeds.

if i click previous button , i need to display some feeds.



I wrote the code in the following way


In main class , i wrote the following code



- (IBAction) nextbutton:(id)sender
{

button= @"next";
RootviewController *vController = [[RootviewController alloc]
initWithNibName:mad:"Newsmenu" bundle:[NSBundle mainBundle]];

......
.....

}

- (IBAction) previousbutton:(id)sender
{
button =@"previous"
RootviewController *vController = [[RootviewController alloc]
initWithNibName:mad:"Newsmenu" bundle:[NSBundle mainBundle]];

......
.....

}

..........end............


In RootviewController i wrote the main operations,so i need to check the variable "button"

if i call the "button" in the RootviewController class it displays null value.

code:
HTML:
result=rootviewcontroller.button

1)What is the way to access the "button" value in RootviewController class.
 

eddietr

macrumors 6502a
Oct 29, 2006
807
0
Virginia
When you say "main class", what do you mean by that?

Why not create a property in the RootViewController and set that variable like this:

Code:
vController.someVar = someValue
 

iphonejudy

macrumors 6502
Original poster
Sep 12, 2008
301
1
v can assign value to a variable easily.

but i want the value of the variable
 

eddietr

macrumors 6502a
Oct 29, 2006
807
0
Virginia
v can assign value to a variable easily.

but i want the value of the variable

I'm not sure if you understood what I said. So your problem is that from your vController you did not have a reference to the rootController.

So you can avoid that problem by setting a property on the vController itself. Then from within that view controller you can read it with:

Code:
self.someVar

Or there are other ways to do this, such as putting a reference to your rootController in the new view controller. Or putting this variable in your appDelegate. Or any number of other options. This is just one way to do it.
 

iphonejudy

macrumors 6502
Original poster
Sep 12, 2008
301
1
Hi,


I need to display feeds based on the button,

I have two buttons called next and previous.


if i click next button , i need to display some feeds.

if i click previous button , i need to display some feeds.



I wrote the code in the following way


In Menuscreen class , i wrote the following code



- (IBAction) nextbutton:(id)sender
{

button= @"next";
RootviewController *vController = [[RootviewController alloc]
initWithNibName:mad:"Newsmenu" bundle:[NSBundle mainBundle]];

......
.....

}

- (IBAction) previousbutton:(id)sender
{
button =@"previous"
RootviewController *vController = [[RootviewController alloc]
initWithNibName:mad:"Newsmenu" bundle:[NSBundle mainBundle]];

......
.....

}

..........end............


In RootviewController i wrote the main operations,so i need to check the variable "button"

if i call the "button" in the RootviewController class it displays null value.

code:
HTML:
result=rootviewcontroller.button

1)What is the way to access the "button" value in RootviewController class.
 

BlackWolf

macrumors regular
Apr 9, 2009
244
0
you already posted that?

there are several ways to do this. the easiest way is to make an IBOutlet with the class "RootViewController" in your Menuscreen class, and then connect that to your root view controller (which probably is your file's owner in IB). this way, you can access everything in your root view controller.
 

eddietr

macrumors 6502a
Oct 29, 2006
807
0
Virginia
you already posted that?

there are several ways to do this. the easiest way is to make an IBOutlet with the class "RootViewController" in your Menuscreen class, and then connect that to your root view controller (which probably is your file's owner in IB). this way, you can access everything in your root view controller.

OK, this is where I got a bit confused earlier. In her case, the RootviewController is not the first view. The Menuscreen seems to be the first view, then it programatically creates a RootviewController and (wants to) set a property on that new instance. So I don't think IB will help here.

But iPhoneJudy, here is what you can do: Just create a property called "button" (or a better name) on RootviewController. Then when you create a new RootviewController, just set the property like so:

Code:
//within your nextButton method:

vController.button = @"next";
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.