Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About migrating to Swift 3 or Swift 4 #58

Closed
josmanperez opened this issue Feb 7, 2018 · 2 comments
Closed

About migrating to Swift 3 or Swift 4 #58

josmanperez opened this issue Feb 7, 2018 · 2 comments

Comments

@josmanperez
Copy link

josmanperez commented Feb 7, 2018

Hello Fahim!,

First of all thank you very much for your fantastic library.. it helps me a lot.
Right now I am developing an app that was made using phonegap and now I have the work to migrate the app to Swift 3.

The app has this "migrationStore" where before launching the app it gathers all the information that was on the local database and uses it to generate a new CoreData model database..

Until now was working just fine.

This was the init process and an example of a method (previously working fine):

private init(){
        if PHONEGAP_MIGRATION {
            db = SQLiteDB.sharedInstance("file__0.localstorage")
            //   db = SQLiteDB.openRO(path: "file__0.localstorage")
        }
    }
public func getLocalStorageUrl() -> String{
        if PHONEGAP_MIGRATION {
            var url = [SQLRow]()
            url = db!.query("SELECT value FROM itemtable WHERE key = ?", parameters: [URL_FIELD])
            for v in url{
                if let value = v["value"]{
                    return value.asString().stringByReplacingOccurrencesOfString("\"", withString: "", options: NSStringCompareOptions.LiteralSearch, range: nil).stringByReplacingOccurrencesOfString("\0", withString: "", options: NSStringCompareOptions.LiteralSearch, range: nil)
                }
            }
            return NTXConfiguration.sharedInstance.serverUrl
        return ""
    }

I am having problems to use the init() method using swift 3

How can I open a database using a file name (string)?

Thank you so much

Regards

@FahimF
Copy link
Owner

FahimF commented Feb 8, 2018

I am not sure if this is a question that can be answered via a GitHub issue - especially since this is not really an issue with SQLiteDB :) You might want to e-mail me about this. But basically, if you want to specify a specific table name, look at the DB_NAME variable. Also note that now there is no SQLRow class since that was removed sometime back - you just get a dictionary back as the results of the query.

You might also want to take a look at the sample code since that works with the new changes and that should give you an idea as to how the usage works.

If you still have questions, please e-mail me since doing this via GitHub is not going to work well :)

@FahimF FahimF closed this as completed Feb 8, 2018
@josmanperez
Copy link
Author

Thank you Fahim, and sorry for asking this type of question (not a bug) using github issues

I'll email you if I have more doubts, again thank you so much for the effort of building and maintaining this wonderful library :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants