tags:

views:

44

answers:

2

Hi guys,

I'm working on handling the click of a customized URL in TTStyledTextLabel.

When I set the text to <a href="appname://user/name">name</a>, TTStyledTextLabel can parse it correctly as a URL But when I try to map this URL to a Viewcontroller, I just can't get the parameter (the 'name')

This is what the code looks like: [map from:@"appname://user/ (initWithName:)" toViewController:[UserInfo class]];

If I change the URL to <a href="appname://user">name</a>, and map it without parameter like: [map from:@"appname://user" toViewController: [UserInfo class]]; I can navigate to the UserInfo class...

Does anyone have this experience before? thanks for the help guys :)

**Edit I actually found it's due to there are unicode in the URL.... seems I need to find a workaround...

A: 

Ensure that the name parameter do not contain one or more slashes: / The parameter can not be parsed correctly to put into the init function.

sfa
I actually found it's due to there are unicode in the URL.... seems I need to find a workaround...
hotsjf
why don't you use the identifier to pass to the URL? then on the receiver, you can easily get it back by querying with the identifier. Otherwise, you may consider using native object in your url, in this case, when your app comes back after restart, this native object will be nil. So, you have to decide.
sfa
thanks, I've used the identifier as a workaround :)
hotsjf
good to hear that it works, sometimes you need to find a simple solution than trying to go much further with a harder one. cheers :)
sfa
A: 

If you need to pass data through URLs, you can also set the userInfo property to be a dictionary of your choosing.

If you're using TTTableItems with URLs, here's a category that will automatically add the table item's userInfo object to the URL's userInfo dictionary with the key __userInfo__.

See my comment at the bottom on how to retrieve the object in the mapped controller.

Michael Grinich