|
Go
![]() |
New
![]() |
Find
![]() |
Notify
![]() |
Tools
![]() |
Reply
![]() |
|
|
Apprentice |
Hello everyone!
I've got a little problem with the MCPObjectContext. I need all contacts in an array and i've tried NSArray *testArray = [[NSArray alloc] initWithArray:[objectContext objectsForEntityNamed:@"Contacts"]]; But Daylite Crashes... I think the solution is really simple, but i'm thinking the wrong way Thanks for Help Thomas |
||
|
|
Marketcircle Team |
Hello.
I am not sure if this will solve your problem or if there is another error, but the first thing that stands out is that Contacts should be Contact: NSArray *testArray = [[NSArray alloc] initWithArray:[objectContext objectsForEntityNamed:@"Contact"]]; That could cause DL to crash. HTH |
|||
|
|
Apprentice |
Hi Michael,
no, Daylite still crashes,, here my full testclass: #import "dayliteConnection.h" #import "MCPObjectContext.h" #import "MCPObject.h" @implementation dayliteConnection -(void)testQuery { MCPObjectContext *objectContext; //MCPObjectContext *DayliteObjectContext = [[MCPObjectContext alloc] init]; NSArray *testArray = [[NSArray alloc] initWithArray:[objectContext objectsForEntityNamed:@"Contact"]]; //NSLog(@"%i",[testArray count]); } @end But anyway, thanks for your help Thanks a lot Thomas |
|||
|
|
Marketcircle Team |
Oh, are you writing a plugin?
The problem is that you cannot create an object context like that, you have to use an already existing one which you can get from a document. There is documentation explaining how to do this here: http://www.marketcircle.com/daylite/developers.html HTH |
|||
|
|
Apprentice |
Hi Michael,
thanks for the help. Can you tell me how i can access the ObjectContext from the document? Sorry for the silly questions i'm a bit confused today :-) Thanks a lot. Greetings from Germany Thomas Bartelmess |
|||
|
|
Marketcircle Team |
The object context hangs off the document, so once you have the document you can get the object context like so:
MCPObjectContext *oc = [document objectContext]; |
|||
|
|
Apprentice |
Hello,
Stupid question but where do i get the document from, i can't compile it. Greetings Thomas |
|||
|
|
Apprentice |
Ok, sorry for being Stupid today.. i got it
Thanks a lot! |
|||
|
|
Marketcircle Team |
Sorry... here is how to get all this stuff: GWDataContext* document = [[NSApplication sharedApplication] firstDocumentWithKindOfClassNamed:@"GWDataContext"]; MCPObjectContext* oc = [document objectContext]; You might get some compiler warnings about not finding methods, but this should run. If you get an error, you might have to add an include for GWDataContext.h Hope that works! |
|||
|
| Previous Topic | Next Topic | powered by eve community |
| Please Wait. Your request is being processed... |
|

