views:

1467

answers:

1

Hi,

following situation:

in a TTTableViewController i added some Cells with URLs. they are opening a class with @"tt://photos" for example. this works quite fine.

the first thing is, i saw some urls in TT Examples like @"tt/photos/1". is it possible to fetch this "1" in my photos class and say, for example okay, please open picture one, ore is this only another URL that was declared in TTNavigatior to open a specific Class?

the other thing is: is it possible to forward an object to the linked class? clicking a cell opens @"tt://photos" (the linked class in my TTNavigator)

working with normal tableviews i can overwrite my init method and send an object with my initialize method, is this also possible by clicking my TTItems?

thanks!

+5  A: 

figured it out myself, for those who need it:

First (passing "subURLs" in your navigator map)

navigating to an URL with @"tt://photos/firstphoto" is possible, you can fetch the "firstphoto" like this:

//Prepare your Navigator Map like this
[map from:@"tt://photos/(initWithNumber:)" toViewController:[PhotoVC class]];

In your PhotoVC you can access this Number:

-(void) initWithNumber: (NSString*)number {
    NSLog(@"%@",number);
}

calling your View Controller with this url would look:

PhotoVC* controller = [[PhotoVC alloc] initWithNumber:@"1"];
[navigationController pushViewController:controller animated:YES];
[controller release];

Second (passing objects in an TTTableViewController)

its a bit tricky, but you dont have to Subclass anything.

first, nil the URL in the TableItem

 [TTTableLink itemWithText:@"TTTableLink" URL:nil]

in your TTTableViewController write down this method

- (void)didSelectObject:(id)object atIndexPath:(NSIndexPath*)indexPath {
     TTURLAction *urlAction = [[[TTURLAction alloc] initWithURLPath:@"tt://photos"] autorelease];
     urlAction.query = [NSDictionary dictionaryWithObject:@"firstphoto" forKey:@"photo"];
     urlAction.animated = YES;
     [[TTNavigator navigator] openURLAction:urlAction];
 }

now in your your PhotoVC you need something like this

- (id)initWithNavigatorURL:(NSURL*)URL query:(NSDictionary*)query {
     if (self = [super init]) {
              NSLog(@"%@",query);
}

     return self;
}

and you are done ;)

choise