xcode - SQLITE_TRANSIENT undefined in Swift -
i'm using xcode 6 , i've imported libsqlite3.dylib
, libsqlite3.0.dylib
. i've added bridging-header.h
file witch imports sqlite3.h
i can open sqlite database , simple operations insert select...
with if (sqlite3_bind_text(compiledstatement, 2, name.cstringusingencoding(nsutf8stringencoding), -1, sqlite_transient) != sqlite_ok)
i have error: use of unresolved identifier 'sqlite_transient'
what show do? i'm new in swift, it's first question on stack, pls me!
the definitions
#define sqlite_static ((sqlite3_destructor_type)0) #define sqlite_transient ((sqlite3_destructor_type)-1)
from <sqlite3.h>
not imported swift, due "unsafe" pointer casting.
a possible swift definition shown in sqlite.swift project, in statement.swift:
let sqlite_static = sqlite3_destructor_type(copaquepointer(bitpattern: 0)) let sqlite_transient = sqlite3_destructor_type(copaquepointer(bitpattern: -1))
for swift 2 need
let sqlite_static = unsafebitcast(0, sqlite3_destructor_type.self) let sqlite_transient = unsafebitcast(-1, sqlite3_destructor_type.self)
(taken "helpers.swift" swift 2 branch of sqlite.swift project).
update swift 3:
let sqlite_static = unsafebitcast(0, to: sqlite3_destructor_type.self) let sqlite_transient = unsafebitcast(-1, to: sqlite3_destructor_type.self)
Comments
Post a Comment