[英]Calling Objective-C from JavaScript in DashCode
我正在用Dashcode创建一个网站。 我非常了解目标c,但几乎一点也不了解javascript。 这是一个示例objective-c类:
/* Here is an example .h file, "CircularList.h".
All behavior is inherited from List, which defines a List of objects.
Nowadays we can use NSArray which is more complex than List.
*/
#include <objc/List.h> /* Superclass interface */
@interface CircularList: List /* List is superclass */
{
int currentLocation;
}
- (NSString *) next; /* Returns next object in List or nil if none. */
@end
/* Here is the corresponding .m file: */
#include "CircularList.h"
@implementation CircularList
- (NSString *) next
{
int numObjects = [self count];
if (currentLocation >= numObjects)
currentLocation = 0;
return [self objectAt:currentLocation++];
}
@end
如何在DashCode中将此类与野生动物园Web应用程序项目连接? 我下一步怎么打电话? 如何将NSString转换为var,然后将var打印到日志?
我看过开发库。 如何将目标c类导入到dashcode项目中?
这是课程:
/* Here is an example .h file, "CircularList.h".
All behavior is inherited from List, which defines a List of objects.
Nowadays we can use NSArray which is more complex than List.
*/
#include <objc/List.h> /* Superclass interface */
@interface CircularList: List /* List is superclass */
{
int currentLocation;
}
- (NSString *) next; /* Returns next object in List or nil if none. */
@end
/* Here is the corresponding .m file: */
#include "CircularList.h"
@implementation CircularList
- (NSString *) next
{
int numObjects = [self count];
if (currentLocation >= numObjects)
currentLocation = 0;
return [self objectAt:currentLocation++];
}
+ (NSString *) webScriptNameForSelector:(SEL)sel
{
if (sel == @selector(nameAtIndex:))
name = [self next];
return name;
}
+ (BOOL)isSelectorExcludedFromWebScript:(S…
{
if (sel == @selector(nameAtIndex:)) return NO;
return YES;
}
@end
如何将目标c与javascript文件或dashcode项目连接? 目标C类要去哪里(例如与js相同的文件夹)? 什么是将我的函数称为“下一个”的JavaScript? 以下代码是做什么的:+(BOOL)isSelectorExcludedFromWebScript:(S…{if(sel == @selector(nameAtIndex :))返回NO;返回YES;}
过了好久...
人们(我们,第三方开发人员)无法从Dashcode调用obj-c,或者至少不可能这样做。 Dashcode是(或曾经)关于可以用javascript编写的非常简单的应用程序。
仪表板框架不会加载任何Objective-C可执行文件,因此建立objc-js桥完全由您决定。 我认为这是不可能的。 至少不只使用Dashboard javascript框架。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.