Closed Sadmansamee closed 8 years ago
Issue solved On https://github.com/siegesmund/SwiftDDP/blob/master/Examples/Dictionary/SwiftTodos/Lists.swift
var collection:MeteorCollection = (UIApplication.sharedApplication().delegate as! AppDelegate).lists
I followed this way then I got that problem there was type mismatch... my mistake when removed ":MeteorCollection" it worked fine...
Glad you solved it!
thanks...but facing another issue like the collection list it not initilized even after successful subscription. Like I declare a variable
You must create a collection that will contain the documents, not a document. Here is an example, from the documentation:
class List: MeteorDocument {
var collection:String = "lists"
var name:String?
var userId:String?
}
let lists = MeteorCollection<List>(name: "lists") // As with Meteorjs, the name is the name of the server-side collection
Meteor.subscribe("lists")
You might declare the collection in your AppDelegate. It doesn't make any sense to declare a document there.
By the way, per your original question: you're running into the basics of Swift's strong typing.
You can write it as:
var collection:MeteorCollection = (UIApplication.sharedApplication().delegate as! AppDelegate).lists
or, more commonly, you can cast it:
var collection = (UIApplication.sharedApplication().delegate as! AppDelegate).lists as! MeteorCollection
This is something that you will run into repeatedly in Swift.
actually that was not my question but I'm clear now.
Great!
hey @siegesmund I'm getting two issue when trying to follow the dictionary way (Simple in-memory persistence)
below