I have an iPhone app with a tableviewcontroller. When you click a certain cell it opens a new uiviewcontroller with this code:
nextViewController = [[avTouchViewController alloc] initWithNibName:@"avTouchViewController" bundle:nil];
The uiviewcontroller above called avTouchViewController has a property that looks like:
IBOutlet SomeObject *controller;
SomeObject is an object with all relevant view properties.
I would like to pass an nsstring parameter from the tableviewcontroller I initialize the avTouchViewController with to someObject.
How can I do this?
If I were doing this I would add my own initializer to my UIViewController subclass:
And then just call the following (in tableView:didSelectRowAtIndexPath: or whereever):
As a point of style, class names conventionally begin with uppercase letters (hence my change to AVTouchViewController).
I'm a little confused by your question; you say you're creating your
avTouchViewController
s when a cell is tapped inside an existingUITableView
, but your last part describes the inverse situation.Basically, if you want to pass information to a view controller, just give it a property that can be set (which may already be the case), e.g.:
You also may want to rename your
controller
property. To a reader, it doesn't make sense that a view controller has a property calledcontroller
which is actually aSomeObject*
. As well, your class names should be capitalized, i.e. useAvTouchViewController
instead ofavTouchViewController
.