您的位置:首页 > 移动开发 > Swift

Swift开发中的一些琐碎

2016-07-05 17:58 381 查看
1、Swift中使用OC

1.创建 pch 文件,直接引用需要的头文件 #import"SQLite3.h"

2.修改 pct 路径 ,如下图,就可以使用了

   


2、 Swift 没有系统定义好的宏,想使用DEBUG模式要自己自定义,如下图

  


3、 自定义print

print(__FILE__) // 获取当前print所在的文件路径
print(__FUNCTION__) // 获取当前print所在的方法名称
print(__LINE__) // 获取当前print所在的行号

fun MyLog<T>(message: T, fileName: String = __FILE__, methodName: String = __FUNCTION__, lineNumber: Int = __LINE__) {
#if DEBUG
print("\((fileName as NSString).pathComponents.last!).\(methodName)[\(lineNumber)]:\(message)")
#endif
}

AppDelegate.swift.application(_:didFinishLaunchingWithOptions:)[24]:ddd

4、使用原始图片

  


5、Swift 中导入 OC库编译错误
  有时候在swift开发中导入 SnapKit 库 遇到编译错误问题,可能是库的版本太高了,你的Xcode 或者 swift 版本还不支持。将库版本降低就OK了。
6、使用git的时候 ,当你先 git add .了之后没有 push到远程仓库,之后又修改,git add . 然后在push 的时候 会提示下面错误

error: failed to push some refs to 'git@git.oschina.net:w_wl/han.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

意思是要你先 git pull 本地merge之后再push 到远程仓库
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: