I am working on a cocoa software and in order to keep the GUI responsive during a massive data import (Core Data) I need to run the import outside the main thread.
Is it safe to access those objects even if I created them in the main thread without using locks if I don't explicitly access those objects while the thread is running.
...
Apple's documentation on -setPrimitiveValue:forKey: is vague in two ways when using it to manage to-many relationships.
First they state:
If you try to set a to-many relationship to a new NSMutableSet object, it will (eventually) fail.
Eventually?! What does that even mean? Will it fail later during -[NSManagedObjectContext save:]...
Is it possible to model relationships between entities that are defined in separate NSManagedObjectModels if the entities are always used within an NSManagedObjectModel that is created by merging the relevant models?
For example, say model 1 defines an entity Foo with relationship (one-to-one) toBar and that model 2 defines an entity Ba...
In my Core Data managed object model, I have an entity Foo with a to-many relationship (with a to-many inverse) to entity Baz named baz. Baz has a string property named "tag". When I use [NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:[NSArray arrayWithObject:@"baz.tag"] inEntityDescription:FooDescription] to create the row ...
How can I modify the NSDatePickerElementFlags for the NSDatePicker in row templates for NSDate properties returned by [NSPredicateRowEditorTemplate templatesWithAttributeKeyPaths:inEntityDescription:]? I would like the NSDatePicker to show hrs:minutes as well as the date.
Update
I've added an answer below, gleaned from the cocoa-dev lis...
A few weeks ago I started using Core Data for the first time in a non-trivial application. One of the things that surprised and confused me was how error handling works. To give an example, one of the first things I tried was setting my data file as "locked" in Finder, to order to make sure I was properly handling the NSError object retu...
Say I have entities organized in a hierarchy with Parent being the root entity and Child being a subclass of Parent. I'd like to setup an NSArrayController to fetch only entities of Parent, but not Child.
If you set the Entity Name of the array controller in Interface Builder to Parent, it fetches all Parent and Child entities. I orig...
In a previous question, I asked about how to filter out subentities from a Core Data fetch request on an array controller. The answer is to customize the fetch request used by the array controller. It seems I can easily do this in one of two ways. First, I could customize the fetch request in fetchWithRequest:merge:error:
- (BOOL)fet...
There might be applications that are not suited for Core Data - image manipulation programs like Photoshop or Gimp for example. But for applications that are suited for Core Data, say Address Book or iCal, what is the criteria to choose Core Data over a custom model?
...
I've got a Core Data application that has an Event class, which has a start date and a finish date. It's trivial to bind these to a pair of NSDatePicker widgets, but I wanted to make it work with the NSRangeDateMode available in Leopard.
The NSDatePicker has a pair of methods that deal with timeInterval, but I don't seem to be able to ...
I am using a modal sheet to edit a certain data entity. This sheet is run as application modal. When the sheet is launched, the object controller in the same nib as the sheet is set to the currently selected NSManagedObject.
The code leading into the launching is as follows:
[objectController setContent:object];
[NSApp beginSheet:[self...
Below is the "work horse" piece of code that I've implemented in order to display a many-to-many relationship in CoreData.
My UI is on a screen called "Expense". This expense can be associated with many transactions. (Also, transactions can be associated with several expenses). The UI contains the currently selected expense, and a table...
The data model for my Core Data document-based app (10.5 only) is in a
framework, so automatic schema upgrades using a Core Data mapping
model don't appear to work. It appears that the Core Data machinery
doesn't find the appropriate data models or mapping model when they
are not in the app's main bundle. So, instead of using the automat...
I have a relationship in a Core Data model that feels like it wants an association class. Specifically, I have a Person object, and a Location object. There is a many-to-many relation between these two classes, which has some properties, such as how many hours this person wishes to work at this location per week.
How do I model this u...
I have subclassed NSPersistentDocument class. I want to add an image to the document. I have an Image Well. How do I set it to a .jpg file?
...
This problem has been kicking my butt for a few days now.
I have a web service that serves XML that looks like this:
<levels>
<level>Level 1</level>
<level>Level 2</level>
<level>Consulting</level>
<level>Office Support</level>
<level>Learning</level>
</levels>
This data needs to go into an entity in my Core Data ...
I've looked through all the class documentation for Core Data and I can't find away to programmatically update values in a core data entity. For example, I have a structure similar to this:
id | title
============
1 | Foo
2 | Bar
3 | FooFoo
Say that I want to update Bar to BarBar, I can't find any way to do this in any ...
I have subclassed NSPersistentDocument. I have renamed the window too. But when I run the application I get the title of the application window as "Untitled". There is no -setTitle: method which I can use to change the title. Any ideas how can I go about doing this?
...
I've been doing iPhone development for the last 5 months or so, and have been using Gus Mueller's FMDB for database interaction. My next project will have both a Mac and an iPhone application, and they will share data between them, although in the end, the iPhone will be mostly a viewer app, with some minor editing capabilities.
My que...
Following the advice in the Core Data Programming Guide's Core Data Performance page
regarding storage of BLOBs, I've chosen to store binary data for my
NSPersistenDocument-based app (Leopard-only, if that makes a
difference) in an external file (separate from the document Core Data
data store) and keeping an archived NDAlias reference t...