|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Journeyman |
I'm looking for a way to elegantly find out, given 2 objects, to establish if there is an existing link between them. This method from objectcontext.h seems like it fits the bill (I think)
// Returns whether the objects are already joined together - (BOOL)efficientlyCheckJoinForObject:(MCPObject *)obj usingManyToManyRelationshipWithKey:(NSString *)relName toObject:(MCPObject *)otherObject; But I guess my question would be, how do I identify the manytomany relationship key? I see that there are primary keys etc, but am not sure what I should be looking for. (For my current purposes, object 1 is a contact and object 2 is a timeblock). And if this isn't the correct approach, I would like to find out the best way to a) find out whether 2 objects are linked, and b) What is the correct way to identify all objects linked to any particular object.. Thank you! -E |
||
|
|
Marketcircle Team |
MCPObject is a 'business object' such as a Contact or a Project - MCPObject is not a primary key.
So to find out if a task is linked to a contact, you do this in Objective-C (the f-script syntax would be a bit different):
MCPObject *myTask; // assuming this exists
MCPObject *myContact; // assuming this exists
MCPObjectContext *objectContext; // assuming this exists
if ([objectContext efficientlyCheckJoinForObject:myContact
usingManyToManyRelationshipWithKey:@"tasks"
toObject:myTask])
{
// the objects are already linked, do what you need to do
}
Check the eomodeld file for what the many-to-many relationship names should be (they are plural such as 'tasks' or 'keywords'). They look a little different than to-one or to-many relationships. Many-to-manies have an 'intermediate' entity (table) and that entity usually has 'join' in the name at the end. Be careful not to confuse a many-to-many with a to-many. The exception to this is Role and Relationship. HTH |
|||
|
|
Journeyman |
Got it. Another little lightbulb above my head now..
Is there a convenient way to identify all objects linked to a particular object, or is it a matter of running through each object type each time? Thanks AJ! |
|||
|
|
Marketcircle Team |
In that case, you just have to cycle through them.
|
|||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|

