Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Creating Plugins    MCPObjectContext
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Apprentice
Posted
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
 
Posts: 29 | Registered: February 16, 2008Reply With QuoteEdit or Delete MessageReport This Post
Marketcircle Team
Picture of Michael Clark
Posted Hide Post
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
 
Posts: 88 | Location: Markham, Ontario | Registered: June 22, 2006Reply With QuoteEdit or Delete MessageReport This Post
Apprentice
Posted Hide Post
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
 
Posts: 29 | Registered: February 16, 2008Reply With QuoteEdit or Delete MessageReport This Post
Marketcircle Team
Picture of Michael Clark
Posted Hide Post
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
 
Posts: 88 | Location: Markham, Ontario | Registered: June 22, 2006Reply With QuoteEdit or Delete MessageReport This Post
Apprentice
Posted Hide Post
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
 
Posts: 29 | Registered: February 16, 2008Reply With QuoteEdit or Delete MessageReport This Post
Marketcircle Team
Picture of Ali Lalani
Posted Hide Post
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];
 
Posts: 108 | Registered: June 15, 2006Reply With QuoteEdit or Delete MessageReport This Post
Apprentice
Posted Hide Post
Hello,

Stupid question but where do i get the document from, i can't compile it.

Greetings Thomas
 
Posts: 29 | Registered: February 16, 2008Reply With QuoteEdit or Delete MessageReport This Post
Apprentice
Posted Hide Post
Ok, sorry for being Stupid today.. i got it smile

Thanks a lot!
 
Posts: 29 | Registered: February 16, 2008Reply With QuoteEdit or Delete MessageReport This Post
Marketcircle Team
Picture of Michael Clark
Posted Hide Post
quote:
Originally posted by tbartelmess:
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


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!
 
Posts: 88 | Location: Markham, Ontario | Registered: June 22, 2006Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

Marketcircle    Forums  Hop To Forum Categories  Extending Daylite  Hop To Forums  Creating Plugins    MCPObjectContext

© Copyright 2006 Marketcircle Inc. All rights reserved.