QuestionAndAnswer
about iOS
about iOS
about iOS
#import "SQLManager.h"
@implementation SQLManager
static SQLManager *manager = nil;
+
(SQLManager *)shareManager {
static dispatch_once_t once;
dispatch_once(&once, ^{
manager = [[self alloc] init];
[manager createDataBaseTableIfNeeded];
});
return manager;
}
-(void)createDataBaseTableIfNeeded {
}
代码如上。书上讲的是为了把SQLite的那些操作和代码分离开来,单独创建了一个SQLManager类,首先要创建一个单例shareManager,为什么一定要创建一个shareManager,并不明白创建一个单例方法的理由。。。
最重要的一个问题!
不知道怎么把那个函数体翻译成swift语言。。
大神求教~
是在看慕课网的视频时候看到的问题,地址是http://www.imooc.com/video/11867
配置swift的环境好像比objective-C的难很多。。。我按照我所能查到的资料已经做了如下工作:
1.在工程里面建立了一个叫sqlite-bridge.h的头文件,并且点击项目名称 - Build Settings- 搜索“bridging” - 单击“Objective-C Bridging Header” - 双击后面后弹出添加文件名,把刚刚创建的头文件名称写进去,书上说这是在添加桥接文件
2.这样运行没有报错,只是我在使用import sqlite3的时候出现了报错,说无法找到模块名,书上说要在工程下面添加一个module文件夹,在里面创建module.map的文件
书上所说的module.map文件里面需要写如下代码:
module sqlite3[system] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iphoneOS.sdk/usr/include/sqlite3.h"
link "sqlite3"
export *
}
module sqlite3simulator[system] {
header "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/include/sqlite3.h"
link "sqlite3"
export *
}
3.然后让在里面写上这些。。。然后我就照做了。。之后还要在配置项里面import path里面添加进去。。我也添加了
4.然后我使用import sqlite3的这个语句,想要开始写数据库的一些操作语句了,写之前我运行了一下
运行的时候产生了报错:
去stackoverflow里面找了解决方法依旧没有奏效。。并不知道为什么。。。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.