Is it a priority to create an official iOS DDP framework to replace Meteor-iOS and ObjectiveDDP, both which seriously lack documentation and examples?
No itâs not currently a priority. I think it would be a great idea to contribute better documentation and examples for meteor-iOS.
As the creator of Meteor iOS, I second Sashkoâs suggestion Iâm fully aware that it could use more comprehensive documentation, but Iâve been working as a core developer at MDG since this Summer and have been caught up in other projects. Right now, Iâm mostly working on improving the Cordova integration.
So it is indeed fair to say that official native clients are not a priority. Meteor is first and foremost a JavaScript platform, and it thus makes sense to focus resources on ways of using JavaScript to develop mobile apps. That doesnât mean there is no place for native clients, but you shouldnât expect official support for this anytime soon.
Since support for Cordova plugins has improved you might look into that as a solution for pieces of native code you really need. That gives you more flexibility and itâs prepared for multi-platform apps.
Hi Martijn,
First thank you for creating the Meteor-iOS client. We have managed to figure out most of what we need to use the framework. We have 2 remaining questions:
-
How can we get to the collection objects?
Right now an object might look like this:<METDocument key: <collection: snippets, ID: SNjmWKEqTAbGDxBxf>, fields: {text = âFirst snippetâ;}>
How can I put this data into a tableView for example, how can we get the âFirst snippetâ as a String?
- Change Notification
Do you have a swift example on how to use the METDatabaseChanges object to ask for information about the changes that occurred?
It would be great if there was just a little basic documentation for the framework in swift to get people started
Thanks!
Glad you find Meteor iOS useful! Right now, the best way to get to know the framework is the Todos example, which is actually written in Swift.
From your questions it seems youâre trying to use the low-level collection-based API. I would advise you to use the Core Data integration instead. This will give you a lot for free, including the ability to use NSFetchedResultsController
to hook up a reactive query to a UITableView
.
If youâre set on avoiding Core Data, there is some documentation about this on a wiki page. The code samples are in Objective-C, but the translation to Swift should be straightforward (there is no Swift-specific API).
I have studied the wiki page in detail, but there is no example in objective-C on how to access the fields. It just states:
âThe client keeps a local cache of documents sent by the server. These can be accessed through the METDatabase and METCollection classes. Documents are represented byMETDocuments and identified by a METDocumentKey. (Keys encapsulate a collectionNameand documentID).â
It would be great with an example on exactly how we can get to the fields, of documents in a collection.
Thank you
You can use keyed subscripts to access the fields, like you would for a dictionary (something like snippet['text']
).
On METDocumentChangeDetails
, you can use fieldsBeforeChanges
, fieldsAfterChanges
or changedFields
(they are all dictionaries).
Again, I strongly advise you to use the Core Data API, as this wil do type conversions for you and also allow you to automatically map relationships.
Ok this helped us a lot. I know what you say about Core Data, but creating a complete data Model is out of our league for now. One more question please, for the method:
updateDocumentWithID(documentID: AnyObject, changedFields:[NSObject : AnyObject])
we need the documentID. How can we extract it ? I tried this:
let users:METCollection = Meteor.database.collectionWithName("users")
let documentID = users.allDocuments[0].documentID
but it returns nil.
Any help is much appreciated. Thank you.
Have you checked whether users.allDocuments[0]
is also nil
?
Hi, yes sure
let dokument = users.allDocuments[0]
print("dokument: \(dokument)")
Console output:
dokument: <METDocument key: <collection: users, ID: kzzw3vcqukD62xEyz>, fields: {
emails = (
{
address = "xxxxxx@gmail.com";
verified = 1;
}
);
profile = {
address = {
city = "";
country = nor;
lineOne = "";
lineTwo = "";
zip = "";
};
card = {
last4 = 4242;
verified = 1;
};
filledOut = 1;
name = {
first = Elon;
last = Musk;
};
phone = 911;
validated = 1;
};
}>
How do I get the kzzw3vcqukD62xEyz id of this document?
dokument.key.documentID
should work here.
Thank you Martijn, that did the trick !
hello @karlml
if i want to get another collection like âlistâ in todo example what is method in swift and server