我正在用 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; }