0

我正在用 Dashcode 创建一个网站。我非常了解objective 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 中的 Safari 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:)) return NO; return YES; }

4

1 回答 1

0

很久以后...

人们(我们,第三方开发者)不能从 Dashcode 调用 obj-c,或者至少这不应该是可能的。Dashcode 是(或曾经是)关于可以用 javascript 编写的非常简单的应用程序。

Dashboard 框架不加载任何objective-c 可执行文件,因此制作objc-js 桥完全取决于您。我认为这是不可能的。至少不只使用 Dashboard javascript 框架。

于 2013-06-11T16:28:55.310 回答