Reputation: 1005
my problem is that this code is giving an error of missing argument for parameter #1 at the beginning of a project:
class ViewController: UIViewController {
@IBOutlet var lineFields: [UITextField]!
var database: COpaquePointer = nil
var result = sqlite3_open(dataFilePath(), &database)
if result == SQLITE3_OK {
sqlite3_close(database)
println("Failed to open connection")
return
}
func dataFilePath() -> String {
let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)
let documentDirectory = paths[0] as NSString
return documentDirectory.stringByAppendingPathComponent("data.sqlite") as String
}
The var result is where the error is, could someone tell me why. I have added the libsqlite3.dylib and created the bridge needed, any help?? Thanks.
Upvotes: 1
Views: 553
Reputation: 9637
As I mentioned in the comment, sqlite3_open takes cString not String
You need to change your call to be like this:
var result = sqlite3_open((dataFilePath() as NSString).UTF8String, &database)
Upvotes: 1