• 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
Problem syncing between core data and NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem syncing between core data and NSTableView


  • Subject: Problem syncing between core data and NSTableView
  • From: Martin van-Eerde <email@hidden>
  • Date: Sun, 28 Jan 2007 16:07:50 +0000

I have been following Apples Core Data Tutorial where there is a NSTableView and search box.

I am trying to do something similar but I want to create a managed object from a selected directory.

The problems that I have are:

a) Unless I insert the new object into the array controller the newly created object is ignored by any search (although it is displayed in the table view.

b) If I click off the new entry and then try to select it again the application crashes with EXC_BAD_ACCESS.

The method I am having trouble with is:

-(IBAction) addSource:(id)sender
{
	int result;

NSOpenPanel *openPanel = [NSOpenPanel openPanel];

[openPanel setAllowsMultipleSelection:NO];
[openPanel setCanChooseFiles:NO];
[openPanel setCanChooseDirectories:YES];

result = [openPanel runModalForDirectory:NSOpenStepRootDirectory() file:nil];

if (result == NSOKButton) {
NSString *selectedPath = [[openPanel filenames] objectAtIndex:0];
ENSourceManagedObject *newSource = [NSEntityDescription insertNewObjectForEntityForName:@"Source"
inManagedObjectContext:[self managedObjectContext]];



[newSource setValue:[selectedPath lastPathComponent] forKey:@"name"];
[newSource setValue:selectedPath forKey:@"path"];
[newSource setValue:[ENSmartMoveCommon fileSystemTypeForPath:selectedPath] forKey:@"fileSystemType"];



//[[self managedObjectContext] save:NULL];
//[sourceController addObject:newSource];
NSLog(@"Did commit %d", [[self managedObjectContext] commitEditing]);
//[[self managedObjectContext] refreshObject:newSource mergeChanges:YES];
//[[self managedObjectContext] processPendingChanges];

[selectedPath release];
}
}


I have tried more or less any combination of the commented out lines!

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: "Normalize" a URL
  • Next by Date: custom NSPopupButton
  • Previous by thread: [ANN] Macresearch has interview with Aaron Hillegass
  • Next by thread: custom NSPopupButton
  • Index(es):
    • Date
    • Thread