2

我正在使用 TTTableSubtitleItem 并希望在触摸时调用一个函数。

TTURLMap *map = navigator.URLMap;
[map from:@"*" toObject:self selector:@selector(calledFunction)];

但是如果我使用它会抛出这个错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSInvocation setArgument:atIndex:]: index (2) out of bounds [-1, 1]'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x02a0f919 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x02b5d5de objc_exception_throw + 47
    2   CoreFoundation                      0x0297fa88 -[NSInvocation setArgument:atIndex:] + 216
    3   regioappv2                          0x000cd3f7 -[TTURLNavigatorPattern invoke:withURL:query:] + 309
    4   regioappv2                          0x000cd57b -[TTURLNavigatorPattern createObjectFromURL:query:] + 206
    5   regioappv2                          0x000ca30e -[TTURLMap objectForURL:query:pattern:] + 241
    6   regioappv2                          0x000d0c8d -[TTBaseNavigator viewControllerForURL:query:pattern:] + 640
    7   regioappv2                          0x000d020b -[TTBaseNavigator openURLAction:] + 843
    8   regioappv2                          0x000c547b TTOpenURL + 139
    9   regioappv2                          0x000b3f9c -[TTTableViewDelegate tableView:didSelectRowAtIndexPath:] + 353
    10  UIKit                               0x00624718 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
    11  UIKit                               0x0061affe -[UITableView _userSelectRowAtIndexPath:] + 219
    12  Foundation                          0x00331cea __NSFireDelayedPerform + 441
    13  CoreFoundation                      0x029f0d43 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
    14  CoreFoundation                      0x029f2384 __CFRunLoopDoTimer + 1364
    15  CoreFoundation                      0x0294ed09 __CFRunLoopRun + 1817
    16  CoreFoundation                      0x0294e280 CFRunLoopRunSpecific + 208
    17  CoreFoundation                      0x0294e1a1 CFRunLoopRunInMode + 97
    18  GraphicsServices                    0x030f12c8 GSEventRunModal + 217
    19  GraphicsServices                    0x030f138d GSEventRun + 115
    20  UIKit                               0x005c0b58 UIApplicationMain + 1160
    21  regioappv2                          0x00002254 main + 102
    22  regioappv2                          0x000021e5 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.

如果我更改了函数名,那么什么也不会发生,所以映射是正确的。

请让我知道我做错了什么,并告诉我您是否需要更多代码。

问候

4

1 回答 1

0

我认为您的选择器calledFunction需要接受 NSURL 类型的参数,尽管我不确定签名。换句话说,我认为three20希望您使用类似的方法

- (void)calledFunction:(NSURL*)theURL { ... }

代替

- (void)calledFunction { ... }

将您的代码更改为(不要错过冒号):

[map from:@"*" toObject:self selector:@selector(calledFunction:)];
于 2010-09-01T20:32:32.157 回答