跳至主要內容

Objective-C

小于 1 分钟

Objective-C

对于苹果的设备环境,我使用苹果平台的编程语言(objective-c)实现了sdk,这样可以在IOS/MAC电脑上面集成Sekiro,

上手使用

#import <Foundation/Foundation.h>
#include "Sekiro.h"

void test(NSDictionary *request, SekiroResponse *response) {
    [response success:[@"\"ok replay objective-c\""  dataUsingEncoding:NSUTF8StringEncoding]];
}


int main(int argc, const char * argv[]) {
    @autoreleasepool {
        SekiroClient *client = [[SekiroClient alloc] init:@"test-objective-c"];
        [client registerAction:@"testAction" handler: test];
        [client start];
        
        // sekiro启动后,运行在新的线程中,所以这里需要sleep一下,否则直接程序就结束了
        [NSThread sleepForTimeInterval:300];
    }
    return 0;
}

注意事项

  • sdk具备多线程包装,无需再考虑多线程问题
  • 由于本人编程能力有限,response只能接受字符串作为返回数据,暂时不支持json或者任意model。这个等同学们有更好的方案的时候欢迎提交代码改动
上次编辑于:
贡献者: liguobao