• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How do you copy a NSManagedObjectContext
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do you copy a NSManagedObjectContext


  • Subject: How do you copy a NSManagedObjectContext
  • From: Martin van-Eerde <email@hidden>
  • Date: Thu, 8 Feb 2007 19:02:56 +0000

Hi,

I have my single window core data application which has all the managed object template code. I want a second class to do some of the persisting for certain objects but am having trouble passing the reference of the managed object context to the second class.

I have for a init method of the second class:

-(id)initWithManagedObjectContext:(NSManagedObjectContext *)moContext
{
	self = [super init];

	moCopy = moContext;

	[moCopy retain];
}

And from the application delegate in the awakeFromNib:

[[OtherClass alloc] initWithManagedObjectContext:[self managedObjectContext]];

moCopy in the subclass gets a reference in the init method but it appears to go out of scope as soon as the init method returns as when I come to use moCopy in another method later it is set to 0x0

In fact I seem to be unable to retain any references passed from AppDelegate to another class, for instance in the other classes interface if have

	id refToAppDelegate;

and call [otherClass setRefToAppDelegate:self] - A reference is passed in and copied to refToAppDelegate, but again the pointer? gets set to 0x0 as soon as the method is exited.


Thanks Martin

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Document object is not being released
  • Next by Date: Re: Lucene/Cocoa integration
  • Previous by thread: Re: Cocoa fonts anti-aliasing issues
  • Next by thread: Re: How do you copy a NSManagedObjectContext
  • Index(es):
    • Date
    • Thread