1

Basically i map my controllers to accept the address class to be passed into the listingpage controller. Which is done here:

[map from:@"tt://listingPage/(initWithResult:)" toViewController:[ListingPageController class]];
[map from:[Address class] name:@"result" toURL:@"tt://listingPage/(initWithResult:)"];

This url is being used in my table item which is being populated in the datasource:

for (Address *result in [(id<SearchResultsModel>)self.model results]) {
      NSString* url = [result URLValueWithName:@"result"];
      TTTableImageItem* tii = [TTTableMessageItem itemWithTitle:[result addressText] 
                                            caption:[result addressText]
                                            text:[result subText] 
                                            imageURL:[result image] 
                                            URL:url];
    [self.items addObject:tii];
}

My app crashes, I am not sure why, seems to be getting an invalidate view. any help would be much appreciated.

4

1 回答 1

0

Three20 基于 URL 的导航指南

[map from:[Address class] name:@"result" toURL:@"tt://listingPage/(initWithResult:)"];

您遇到的问题是您的代码正在尝试调用实例(initWithResult:)上的方法。[Address class]

相反,您需要做的是Result从实例中检索参数Address并使用它来形成您的 URL。

例子:

@interface ListingPageController : UIViewController
    - (id)initWithResult:(NSNumber *)resultId;
@end

@interface Address : NSObject
    @property (nonatomic, copy) NSNumber *resultId;
@end

因此,在这种情况下,您需要将resultIdfrom传递Address给您的initWithResult:电话 on ListPageController

[map from:[Address class] name:@"result" toURL:@"tt://listingPage/(resultId)"];   
[map from:@"tt://listingPage/(initWithResult:)" toViewController:[ListingPageController class]]; 

请注意,其中没有冒号- 因为这是(resultId)一个属性 getter 方法调用。

按照示例:

Address *result = [[[Address alloc] init] autorelease];
result.resultId = [NSNumber numberWithInt:12345];
NSString* url = [result URLValueWithName:@"result"];
[[TTNavigator navigator] openURLAction:[TTURLAction actionWithURLPath:url]];

这将首先转换result为 URL tt://listingPage/12345,然后打开该 URL,然后调用ListingPageController initWithResult:12345.

于 2012-05-16T00:05:20.393 回答