0

我对 Objective-C 缺乏经验,这是我第一次尝试 Swift。我无法编译 Xcode。(我也可能缺少一两行必要的行,但如果我让它编译,我通常可以找出其余的)

我一直在阅读文档并开始使用,如果它在那里,我不知道答案:http:
//bustoutsolutions.github.io/siesta/guide/objc/
https://bustoutsolutions.github.io /午睡/api/

我的代码:

// MyAPI.swift
import Siesta
import SwiftyJSON

@objc class MyAPI: Service {
    internal static let instance = MyAPI(baseURL:"https://api.example.com")
}

// ViewController.mm
#import "ViewController.h"
#import "PlateScanner.h"
#import "Plate.h"
#import "MyProject-swift.h"
...
- (IBAction)callAPI:(id)sender
{
   [[MyAPI.instance resource:@"/profile/"] child:@"123"];
}

-(void)resourceChanged: (BOSResource*) resource event: (NSString*)   event {
    if([event hasPrefix:@"NewData"]) {
        NSLog(@"%@",[resource text]);
    }
}
...

我从 ViewController.mm 收到以下 2 个错误:
1. 行开头“[[MyAPI”:没有可见的 @interface for 'MyAPI' 声明选择器“资源:”
2. 行开头“-(void)reso”:预期类型

由此我了解到我的 ViewController 不了解必要的 BOSResource 类型,但我不知道如何正确导入 swift 库?

Xcode 生成的代码:

//MyProject-swift.h
...
SWIFT_CLASS("_TtC10MyProject5MyAPI")
@interface MyAPI : BOSService
+ (MyAPI * _Nonnull)instance;
@end
...

开始“@interf ...”行中出现错误:找不到“BOSService”的接口声明,“MyAPI”的超类

任何帮助是极大的赞赏!

4

0 回答 0