Converting ToDoLite to latest Swift

I’m learning Swift, and found a Github project converting the ToDoLite app to Swift. Only thing is it was done for Beta 4 of Swift, so code is quite out of date. I spent some time this evening fixing loads of compiler errors but left with two that I can’t figure out:

self = [super initWithDocument:doc]; // No visible @interface for 'CBLModel' declares the selector 'initWithNewDocumentInDatabase:' link
self = [super initWithNewDocumentInDatabase: database]; //No visible @interface for 'CBLModel' declares the selector 'initWithDocument:' link

I see in the docs that those init methods should exist, or are the docs out of date?

The init methods for CBLModel were removed in the 1.1 release.
You can use the factory methods instead:

Looking at the CBLModel docs on the mobile portal they still reference the initialisers. Sorry about that, we’ll fix that asap.

James

As James says, we had to make an incompatible change in the API to fix some problems. You’re not the first to be confused.

Remember that the framework headers are available as documentation too, and are (by definition) accurate. They even contain doc-comments for every entity. Command-clicking an identifier will take you to the header defining it, and in Xcode 6 you can also option-click to see the documentation in a pop-up.

Thanks guys, I ended up looking at the up to date iOS ToDoLite example which showed me which methods to use. Obviously the example project I’m looking at was written a while ago and has not been updated for CBL 1.1. And yes of course looking at header files is always a sure way to see what methods are available. Sorry for the late response on this.

Are there any plans to create a Swift version of the latest ToDoLite example? I’ve hit an issue with my version which causes it to crash on loading the detail view (due to a nil UITextField, posted on StackOverflow)

Would be useful for those of us wishing to see a full fledged working example of CBLite in Swift.

Not currently.
We’re working on smaller sample apps.
In swift, there’s one for showing a progress indicator


and one with ios share extensions (it’s only using the Sync Gateway REST API for this one though, no embedded couchbase lite database yet :frowning:)

James

There’s a Swift branch of grocery-sync too.

Also, I posted a comment on SO: “Set breakpoints at the start of configureView and viewDidLoad and see which one is called first. It sounds like configureView gets called first. You’d need to fix the calling code to not call it so early.”

Agree!` It would also be good to have a Swift version of the CBEvents tutorial.