【发布时间】:2017-11-02 19:46:48
【问题描述】:
iOS 下 Titanium SDK >= 6.1.0 GA 和 Ti.App.fireEvent 存在问题。在使用带有 JSON 字典作为参数的 Ti.App.fireEvent 的 SDK 6.0.4 GA 之前工作正常,但从 6.1.0 到最后一个 GA (6.3.0) 我收到以下消息:
Listener callback is of a non-supported type: __NSDictionaryM
我在 KrollBridge.m 中看到了可能导致此日志消息的这一行:
- (void)fireEvent:(id)listener withObject:(id)obj remove:(BOOL)yn thisObject:(TiProxy*)thisObject_
{
if (![listener isKindOfClass:[KrollCallback class]])
{
NSLog(@"[ERROR] listener callback is of a non-supported type: %@",[listener class]);
return;
}
KrollEvent *event = [[KrollEvent alloc] initWithCallback:listener eventObject:obj thisObject:thisObject_];
[context enqueue:event];
[event release];
}
ONLY 在设备上试用该应用时失败,但在模拟器上运行正常!
添加一些 NSLog 并运行应用程序:
控制台:
Simulator:
[DEBUG] : Firing app event: event_test
[DEBUG] : Listener type: KrollCallback
[DEBUG] : OK
Device:
[DEBUG] : Firing app event: event_test
[DEBUG] : Listener type: __NSDictionaryM
[ERROR] : Listener callback is of a non-supported type: __NSDictionaryM
代码:
Ti.App.addEventListener('event_test', fun);
Ti.App.fireEvent('event_test', data: {"ID": 0, "Value": "Test"});
我不知道为什么。我感觉这是 6.1.0 GA 中引入的一个错误,它会重现,直到最后一个 GA 可用。
有什么建议吗? 谢谢
【问题讨论】:
标签: titanium appcelerator