Comments (10)
No, you don't need to use a special package. But you will have to make sure to either use reference fields with conventional names or customize the mapping.
from meteor-ios.
You could send related objects from the server with https://github.com/englue/meteor-publish-composite
from meteor-ios.
I have an optional field createdBy in my application. When I define this das an string in my model and in the datamodel i get as value the id of of the user created this object.
@NSManaged var createdBy: String?
@NSManaged var createdBy: User?
If I switch it two be an User in my model and create a relationship in the datamodel i always get nil for this field.
I also have trouble just declare it as a string because i don't know how to fetch and object by the meteor _id with this framework.
@callmeahab we use this package on the server and in the web this works fine.
from meteor-ios.
You can send the user object from the server using publishComposite.
Or you can declare a separate field on the object that has createdBy, then fetch the user from the server. To do this you need to subscribe to users collection, then apply a fetch predicate to a fetch request. To get the mongo id of the object you can do let userId = Meteor.documentKeyForObjectID(user.objectID).documentID as! String
.
from meteor-ios.
I use publishComposite but it does not work for me with in the iOS app.
from meteor-ios.
I still try to get the user that belongs to the event. This code crashes when i print the username.
if let userKey = event.createdBy {
let id = Meteor.objectIDForDocumentKey(METDocumentKey(collectionName: "user", documentID: userKey))
let user = Meteor.mainQueueManagedObjectContext.objectWithID(id) as! User
print(user.username)
}
from meteor-ios.
Are you sure you're publishing the user? Can you check to see if user
is nil?
Also, you shouldn't need to manually look up a relationship value. You should be able to just define a createdBy
relationship in the managed object model and use:
@NSManaged var createdBy: User?
By default, this will look for a field named createdById
, but you can customize the mapping.
from meteor-ios.
How would I customize the mapping?
Am 01.08.2015 um 03:29 schrieb Martijn Walraven [email protected]:
Are you sure you're publishing the user? Can you check to see if user is nil?
Also, you shouldn't need to manually look up a relationship value. You should be able to just define a createdBy relationship in the managed object model and use:
@NSManaged var createdBy: User?
By default, this will look for a field named createdById, but you can customize the mapping.—
Reply to this email directly or view it on GitHub #48 (comment).
from meteor-ios.
You can specify a fieldName
as userInfo
in the model editor (see Todos example).
from meteor-ios.
@martijnwalraven Thanks the problem was the default mapping does not apply to our server.
from meteor-ios.
Related Issues (20)
- When using local IP of my macbook where meteor is running not able to connect to iPhone (ws://local IP:4000/websocket) HOT 1
- managedObjectContext nil - NSFetchedResultsController
- How to refactor METAccount so we can pass in our own service and access group to keychain?
- [IOS][1.3+] WKWebView terminated [White Screen of Death] - kills Geofence events HOT 5
- Not able to get the document ID from the collection. HOT 3
- hello @import Meteor;
- You this is written in Swift, please HOT 1
- preform complex fetches via METFetchRequest to METDatabase#executeFetchRequest:
- Mobile-config.js - App.info: Team HOT 1
- Application crash after assertionFailure in sendMessage Meteor/METDDPConnection.m:74 HOT 1
- How to listen subscription with METDDPClient HOT 1
- retry opening connection
- How to to get notified for specific collection changes?
- How to correctly use updateDocumentWithID? HOT 2
- Support meteor 1.5?
- How to log Out in Swift?
- Custom Mapping to Coredata
- Is this still being maintained? HOT 1
- How to listen to the subscriptions?
- Library not loaded: @rpath/InflectorKit.framework/InflectorKit
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-ios.