[英]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.