有没有办法使用swift2创建表并使用swift2在backendless.com数据库中保存数据?我找到了Objective-C的代码。
Objektiv-C代码:
-(void)saveNewContact
{
Responder *responder = [Responder responder:self selResponseHandler:@selector(responseHandler:) selErrorHandler:@selector(errorHandler:)];
Contact *contact = [Contact new];
contact.age = 21;
contact.title = @"title";
contact.name = @"name";
contact.phone = @"555-555-555";
id<IDataStore> dataStore = [backendless.persistenceService of:[Contact class]];
[dataStore save:contact responder:responder];
}
网址:https://backendless.com/documentation/data/ios/data_saving_data_objects.htm
答案 0 :(得分:0)
以上代码转换为Swift
func saveNewContact() {
var responder: Responder = Responder.responder(self, selResponseHandler: "responseHandler:", selErrorHandler: "errorHandler:")
var contact: Contact = Contact()
contact.age = 21
contact.title = "title"
contact.name = "name"
contact.phone = "555-555-555"
var dataStore: IDataStore = backendless.persistenceService.of(Contact.self)
dataStore.save(contact, responder: responder)
}
希望这可能会有所帮助。
答案 1 :(得分:0)
如果您再次检查该页面,现在在Objective C和Swift中都有示例。