Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 4, 2006, 07:55 PM   #1
HungrySeacow
macrumors regular
 
Join Date: Jan 2006
Location: West Palm Beach
Need a little help with CoreData, insertNewObjectForEntityForName:

Anyone here think they can help me with this problem with CoreData? I need a method that will add an object to an entity, whose contentSet is bound to another entities selection. Right now I have:
Code:
NSManagedObject *source;
source = [NSEntityDescription insertNewObjectForEntityForName:@"secondEntity"
             inManagedObjectContext: [self managedObjectContext]];
Unfortunately, this doesn't work because it is bound to the contentSet of another entity.
__________________
|||||| YummySoup! - Recipe management and sharing at its best!
HungrySeacow is offline   0 Reply With Quote
Old Apr 4, 2006, 11:34 PM   #2
HungrySeacow
Thread Starter
macrumors regular
 
Join Date: Jan 2006
Location: West Palm Beach
OK, I have created a sample program that demonstrates my problem:
http://www.hungryseacow.com/Personal...aTableView.zip

The Manual Add Method button for the Source managedObject works fine, However the one for the Results managedObject does not. Take a look at the methods in the __AppController.m file

- (IBAction)addResultid)sender
and
- (IBAction)addSourceid)sender

Now if you look at the Results NSArrayController, you can see that it has two bindings, the contentSet is bound to the Source's selection. There must be some way to modify this method to get it to also work with the contentSet.

Code:
- (IBAction)addResult:(id)sender
{
	NSLog(@"addResult called");
		NSManagedObject *source;
		source = [NSEntityDescription insertNewObjectForEntityForName:@"Result"
												  inManagedObjectContext: [self managedObjectContext]];
		[[self managedObjectContext] processPendingChanges];
		
}
__________________
|||||| YummySoup! - Recipe management and sharing at its best!
HungrySeacow is offline   0 Reply With Quote
Old Apr 5, 2006, 04:43 PM   #3
HungrySeacow
Thread Starter
macrumors regular
 
Join Date: Jan 2006
Location: West Palm Beach
I don't know why I didn't think of this before! I fixed the problem. I created an IBOutlet to the NSArray Controller called resultArrayController and then sent it this message:
Code:
	NSManagedObject *source;
	[resultArrayController add: source];
EDIT: Sorry the solution that I had before was wrong, now it has been corrected.
__________________
|||||| YummySoup! - Recipe management and sharing at its best!

Last edited by HungrySeacow; Apr 5, 2006 at 11:23 PM.
HungrySeacow is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
coredata doesn't support iOS7 manga iPhone and iPod touch Apps 1 Sep 25, 2013 12:37 PM
insertNewObjectForEntityForName KieferThomas Mac Programming 5 Mar 17, 2013 01:49 PM
unrecognized selector sent to instance with Coredata and Category of NSMangedObject roeik iPhone/iPad Programming 5 Sep 5, 2012 06:40 AM
Coredata has App base and text files as backend for syncing mraheel iPhone/iPad Programming 0 Aug 8, 2012 11:59 PM
AirPrint CoreData Advice? truehybridx iPhone/iPad Programming 1 Jun 17, 2012 10:50 PM

Forum Jump

All times are GMT -5. The time now is 07:46 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC