我对Objective-C缺乏经验,这是我第一次尝试使用Swift。我无法让Xcode编译。 (我可能也错过了必要的一两行,但如果我把它编译好,我通常可以弄清楚其余的一行)
我一直都是文档并且已经开始了,我不知道答案是否存在:
http://bustoutsolutions.github.io/siesta/guide/objc/
https://bustoutsolutions.github.io/siesta/api/
我的代码:
c.execute('INSERT INTO marketTypes (id, name, href) VALUES (?, ?, ?)',
(data['id_str'], data['type']['name'], data['type']['href']))
我从ViewController.mm得到以下2个错误:
1.行开头“[[MyAPI”:'MyAPI'没有可见的@interface声明选择器'资源:'
2.行首“ - (void)reso”:预期类型
据我所知,我的ViewController不了解必要的BOSResource类型,但我不知道如何正确导入swift库?
Xcode生成的代码:
// 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]);
}
}
...
错误的行开头“@interf ...”:找不到'BOSService'的接口声明,'MyAPI'的超类
非常感谢任何帮助!