Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Module 在哪里放置ti.worker钛模块的工人文件?_Module_Titanium_Worker - Fatal编程技术网

Module 在哪里放置ti.worker钛模块的工人文件?

Module 在哪里放置ti.worker钛模块的工人文件?,module,titanium,worker,Module,Titanium,Worker,我已经安装了模块,但我不知道我的worker.js文件应该放在项目中的什么位置。这是一个合金项目,我试着把文件放在几个不同的地方 为了测试,我将我的员工精简为: worker.addEventListener('message', function(event){ worker.postMessage('complete'); }); 我不断地发现这个错误: The application has crashed with an uncaught exception 'NSInvalid

我已经安装了模块,但我不知道我的worker.js文件应该放在项目中的什么位置。这是一个合金项目,我试着把文件放在几个不同的地方

为了测试,我将我的员工精简为:

worker.addEventListener('message', function(event){
   worker.postMessage('complete');
});
我不断地发现这个错误:

The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
[DEBUG] Reason:
[DEBUG] *** -[NSURL initFileURLWithPath:]: nil string parameter
[DEBUG] Stack trace:
[DEBUG] 0   CoreFoundation                      0x03475012 __exceptionPreprocess + 178
[DEBUG] 1   libobjc.A.dylib                     0x03082e7e objc_exception_throw + 44
[DEBUG] 2   CoreFoundation                      0x03474deb +[NSException raise:format:] + 139
[DEBUG] 3   Foundation                          0x00cb0281 -[NSURL(NSURL) initFileURLWithPath:] + 94
[DEBUG] 4   Foundation                          0x00cb020b +[NSURL(NSURL) fileURLWithPath:] + 67
[DEBUG] 5   Swap-A-Doodle                       0x00046259 -[KrollBridge evalFileOnThread:context:] + 265
[DEBUG] 6   libobjc.A.dylib                     0x03096705 -[NSObject performSelector:withObject:withObject:] + 77
[DEBUG] 7   Swap-A-Doodle                       0x0004bbd1 -[KrollInvocation invoke:] + 145
[DEBUG] 8   Swap-A-Doodle                       0x0004e108 -[KrollContext invokeOnThread:method:withObject:callback:selector:] + 248
[DEBUG] 9   Swap-A-Doodle                       0x00046a9d -[KrollBridge evalFile:callback:selector:] + 125
[DEBUG] 10  Swap-A-Doodle                       0x000479b1 -[KrollBridge didStartNewContext:] + 2657
[DEBUG] 11  libobjc.A.dylib                     0x030966b0 -[NSObject performSelector:withObject:] + 70
[DEBUG] 12  Swap-A-Doodle                       0x0004f0ef -[KrollContext main] + 3199
[DEBUG] 13  Foundation                          0x00ce40d5 -[NSThread main] + 76
[DEBUG] 14  Foundation                          0x00ce4034 __NSThread__main__ + 1304
[DEBUG] 15  libsystem_c.dylib                   0x977a1ed9 _pthread_start + 335
[DEBUG] 16  libsystem_c.dylib                   0x977a56de thread_start + 34
[DEBUG] 2013-01-30 19:10:35.372 Swap-A-Doodle[24095:1da0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
[DEBUG] *** First throw call stack:
[DEBUG] (0x3475012 0x3082e7e 0x3474deb 0xcb0281 0xcb020b 0x46259 0x3096705 0x4bbd1 0x4e108 0x46a9d 0x479b1 0x30966b0 0x4f0ef 0xce40d5 0xce4034 0x977a1ed9 0x977a56de)

将其放在
app/lib
中,
app/lib
中的所有文件都将放在生成的
Resources/
目录的底部,这样您就可以在任何用于实例化worker的控制器中访问worker.js,如下所示:

var worker = require('ti.worker');

// create a worker thread instance
var task = worker.createWorker('worker.js');
task.postMessage({
   msg:'Hello'
});

这会将消息发布到worker.js文件中。还没有测试过,祝你好运

这是SDK 2.1+的一个问题,没有计划的修复

我已经试过了,但是我得到了上面描述的同样的错误。这是一个演示