Re: Core Data mergeChangesFromContextDidSaveNotification: does not *completely* update the context ?

2010-12-20 Thread Ben Trumbull
On Dec 19, 2010, at 9:49 PM, Aurélien Hugelé wrote: Hi! I think mergeChangesFromContextDidSaveNotification: does not work as most people expect: I have a mainthread and a subthread. My subthread updates a managed object (change one of the property value) and save. In the mainthread, I

re: KVO and Core data

2010-08-09 Thread Ben Trumbull
Hi all, I have a KVO registration like this: [self addObserver:self forKeyPath:@toOne.attribute options:0 context:NULL]; I establish this on -awakeFromInsert or -awakeFromFetch, and have the corresponding removeObserver called on -willTurnIntoFault. The problem is that when I do a

re: Core Data : Multiuser ?

2010-08-07 Thread Ben Trumbull
Can more than one process be accessing the same Core Data sqlite file? This post from author Marcus Zarra says no∑ http://forums.pragprog.com/forums/90/topics/1476 But this post from Ben Trumbull seems to say yes, as long as the two processes are accessing it via the same filesystem

re: Core Data : Multiuser ?

2010-08-07 Thread Ben Trumbull
p.s. http://www.cocoabuilder.com/archive/cocoa/283632-coredata-database-sharing-and-migration.html#283632 - Ben ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the

Re: Core Data : Multiuser ?

2010-08-07 Thread Ben Trumbull
: Given those limitations, how does one enable support for a 10.6+ target? On Aug 6, 2010, at 11:38 PM, Ben Trumbull wrote: It possible, but inefficient, for a very limited number of clients to share over AFP. NFS doesn't work correctly at all. This is restricted by file caching issues

Re: Core Data : Multiprocess (was Multiuser) ?

2010-08-07 Thread Ben Trumbull
Sorry. I see I've created confusion by putting Multiuser in the subject. I should have said Multiprocess yeah. Yes, several Apple frameworks use Core Data databases from multiple processes simultaneously with a single user account and single physical machine. Later, a reference is

Re: Cant read second table from same sqlite database iphone

2010-04-11 Thread Ben Trumbull
to ther users docuement directory success = [fileManager copyItemAtPath:dbPath toPath:databasePath error:error]; if (!success) NSAssert(0,@Failed to copy Database!\n); } From: Ben Trumbull trumb...@apple.com To: cnape...@yahoo.com Cc: Cocoa dev cocoa-dev

re: Cant read second table from same sqlite database iphone

2010-04-10 Thread Ben Trumbull
Hello All, I am having trouble reading the second table from my database because it returns nothing even if there is data inside it. How do you know it has data inside it ? A common mistake is to try to write to databases in the read only part of an application's sandbox on the iphone.

re: Problem with vCard and AddressBook ABPerson UID, HELP!!

2010-04-07 Thread Ben Trumbull
've been fighting now with the AdressBook API for a while and found a disturbing problem. Maybe someone can help. I'm trying to use the AddressBook as my main person database in my application. I've create a small function that accepts drag - drops from the Address book to add a new

Re: Finding managed objects by URI representation

2010-04-05 Thread Ben Trumbull
On Apr 5, 2010, at 8:18 AM, Gideon King wrote: On 05/04/2010, at 6:51 AM, Ben Trumbull wrote: No, this is going the wrong way. The objectID is the object's identity in the persistent store (e.g. primary key). You don't need to store pieces of it somewhere else. NSPredicate

re: Finding managed objects by URI representation

2010-04-04 Thread Ben Trumbull
I have some queries that used to look up objects based on an elementID attribute, which used to be my unique identifier for objects, created when the objects were inserted or loaded. I am now moving away from that and using the standard managed object IDs and reference objects. So I used

re: iPhone CoreData TableView not updating

2010-04-03 Thread Ben Trumbull
I did the first 7 chapters of More iPhone 3 Development, tackling iPhone SDK3 from Apress regarding the use of CoreData. In these 7 chapters a lot is explained and finally a series of classes and categories are being build that one can use as a Generic Controller for editing data stored in

re: Invalidated managed objects

2010-04-03 Thread Ben Trumbull
When I create a document, save it, then save as, then save as again, it duplicates the persistent store, so the managed objects I have been using in my application are all invalidated. Now there are a whole lot of places in my application where I have KVO set up on properties of the

Re: NSPredicate/NSExpression - can they solve this Core Data problem?

2010-04-03 Thread Ben Trumbull
2, 2010, at 3:42 PM, Ben Trumbull wrote: NSComparisonPredicate* exprPred = (NSComparisonPredicate*)[NSPredicate predicateWithFormat:@SUBQUERY(self, $key, %...@.$key != nil) == 0, obj]; NSExpression* expr = [exprPred leftExpression]; NSLog(@expression subquery results

Re: Invalidated managed objects

2010-04-03 Thread Ben Trumbull
On Apr 3, 2010, at 5:07 PM, Gideon King wrote: Wow, this is huge! Obviously the user doesn't expect the document to disappear and a new one open up just because they did a Save As operation I have I'm afraid led you astray. The invalidated objects are not coming from the Save As operation.

Re: Invalidated managed objects

2010-04-03 Thread Ben Trumbull
On Apr 3, 2010, at 6:25 PM, Gideon King wrote: Phew, that's a relief. I'll look forward to hearing what I'm doing wrong in my sample project then. Regards Gideon On 04/04/2010, at 11:22 AM, Ben Trumbull wrote: On Apr 3, 2010, at 5:07 PM, Gideon King wrote: Wow, this is huge

Re: Invalidated managed objects

2010-04-03 Thread Ben Trumbull
On Apr 3, 2010, at 9:44 PM, Gideon King wrote: Excellent, thanks for that. I thought that once a managed object ID had been assigned, that newReferenceObjectForManagedObject: should always return the same value, so I was regenerating it from the previous data instead of generating a new

re: NSPredicate/NSExpression - can they solve this Core Data problem?

2010-04-02 Thread Ben Trumbull
Objects: - NSManagedObject *item - some managaged object - NSArray *attributes - an array of the item's attributes Desired Result: - a possibly smaller array of attribites where [item valueForKey:an attribute] != nil. In code, I can simply iterate over the keys, perform the

Re: NSPredicate/NSExpression - can they solve this Core Data problem?

2010-04-02 Thread Ben Trumbull
On Apr 2, 2010, at 1:30 PM, David Hoerl wrote: Having the array of attributes unrolled separately is a little odd. Do you mean you have an array of attribute names from, say the entity, and you want to ask a MO for all its non-nil attribute values and get back an array of matching

Re: Core Data doesn't save toMany relations please HELP :S

2010-03-29 Thread Ben Trumbull
So was digging more into the problem, and realize that the Items are being saved the ItemXInvoice are being saved and related to the invoice, but I can't acces the invoice detail (ItemXInvoice) immediately I get a console error: The array controller doesn't appreciate what you're doing to

re: NSSortDescriptor and Block

2010-03-24 Thread Ben Trumbull
while experimenting with sorting methods I got a strange error message with -sortDescriptorWithKey:ascending:comparator:. In the following listing (as simple as possible) an Array can be sorted with -sortedArrayUsingDescriptors: with a selector, and -sortedArrayUsingComparator: But

Re: NSSortDescriptor and Block

2010-03-24 Thread Ben Trumbull
comparator:^NSComparisonResult(id obj1, id obj2) { is sorting the array without claims. The syntax of that method is a bit confusing. When using a selector the key is required, and when using a comparator it is not. Thanks again, Jochen Moeller Am 24.03.2010 um 11:12 schrieb Ben Trumbull

Re: Merge changes between two Managed Object Contexts

2010-03-23 Thread Ben Trumbull
If you saved the temporary MOC, then all you have to do is call -[NSManagedObjectContext mergeChangesFromContextDidSaveNotification:] on the main MOC with the save notification from the temporary MOC. It's moving unsaved changes around that's cumbersome. - Ben Thank you Joanna, that was

Re: CoreData database sharing and migration

2010-03-23 Thread Ben Trumbull
On Mar 22, 2010, at 4:06 AM, Steve Steinitz wrote: On 18/3/10, Ben Trumbull wrote: there wasn't a good solution for multiple machines simultaneously accessing an SQLite db file (or most other incrementally updated binary file formats). By good I mean a solution that worked reliably

Re: CoreData database sharing and migration

2010-03-20 Thread Ben Trumbull
that ? (multiple processes, single machine, one SQLite database) I'm thinking of CalendarStore, AddressBook framework. Can you describe what is the general idea behind those Apple frameworks? Aurélien, Objective Decision Team On 17 mars 2010, at 22:29, Ben Trumbull wrote: I am

Re: Checking integrity of a Core Data document with SQLite store

2010-03-18 Thread Ben Trumbull
was sure provided good coverage of the physical file. Dave On 2010-03-15, at 11:03 PM, Ben Trumbull wrote: On Mar 15, 2010, at 7:49 PM, Dave Fernandes wrote: On 2010-03-15, at 3:30 PM, Ben Trumbull wrote: Running an integrity check can be useful if you have previously gotten

re: CoreData database sharing and migration

2010-03-18 Thread Ben Trumbull
On 17/3/10, cocoa-dev-requ...@lists.apple.com wrote: Do you mean more than one application simultaneously on more than one physical computer over NFS/AFP/SMB ? Don't do that. When did that become the official policy, Ben? The short answer is in 10.6. The longer answer is that there are

re: Multiple validation errors. Why?

2010-03-18 Thread Ben Trumbull
I have a core data application. One entity is Hit. This entity typically has no instances when the application starts, and gets populated during the execution of the program. All of the instances appear to be OK when viewed in a TableView. Some or all instances may get deleted before the

re: User-space threads and NSAutoreleasePool

2010-03-18 Thread Ben Trumbull
The problem is that when you call swapcontext() to switch the user-thread running on a kernel-thread, the NSAutoreleasePool stack is not swapped out. It remains rooted in thread-local storage. As a result, serious problems result. Let me give an example. - (void)doStuff {

Re: NSManagedObject awakeFromFetch not sent on secondary thread?

2010-03-17 Thread Ben Trumbull
However I still don't understand why awakeFromFetch is not sent in secondary thread - I can't find any clue in documentation? Is this a bug or is it a feature? I'm running on 10.6.2. Did you try setting the NSFetchRequest option -setReturnsObjectsAsFaults:NO ? The default setting will

re: CoreData database sharing and migration

2010-03-17 Thread Ben Trumbull
I am wondering whether it is possible to create a database in core data that can be opened by more than one application at the same time. It is currently impossible to handle one SQLite database with two instances of the same app. The problem is if user1 quits the app, the data is

Re: CoreData database sharing and migration

2010-03-17 Thread Ben Trumbull
NSDocument based techniques -- it is really just one core data DB. Thank you! Regards, Tobias On Mar 17, 2010, at 10:29 PM, Ben Trumbull wrote: I am wondering whether it is possible to create a database in core data that can be opened by more than one application at the same time

Re: CoreData database sharing and migration

2010-03-17 Thread Ben Trumbull
, Thanks so much for this brilliant suggestion, I haven't thought about something like this before but it's actually really fantastic. About the second question -- do you know how to solve the migration with more than two data models? - Tobias On Mar 17, 2010, at 11:13 PM, Ben Trumbull

Re: Checking integrity of a Core Data document with SQLite store

2010-03-15 Thread Ben Trumbull
On 14 Mar 2010, at 9:47 PM, mmalc Crawford wrote: On Mar 14, 2010, at 7:21 pm, Dave Fernandes wrote: So my question is - how do you detect this before loading the file? I'm aware of the sqlite3 PRAGMA integrity_check, but there does not seem to be a C API for this. Any pointers?

re:NSManagedObject awakeFromFetch not sent on secondary thread?

2010-03-15 Thread Ben Trumbull
My custom NSManagedObject subclass uses awakeFromInsert and awakeFromFetch to setup custom object to ivar. This works as expected, but when I fetch the same object on secondary thread (in NSOperation), the ivar remains nil as awakeFromFetch is not sent... Is NSManagedObject's awakeFromFetch

Re: Problem with save as and freed managed object context

2010-03-15 Thread Ben Trumbull
One of the other things I had been working on must have fixed the underlying problem, and my implementation of identifier and setIdentifier were actually causing this issue. I completely removed those two methods (which is of course going directly against the documentation at the top of the

Re: Checking integrity of a Core Data document with SQLite store

2010-03-15 Thread Ben Trumbull
On Mar 15, 2010, at 7:49 PM, Dave Fernandes wrote: On 2010-03-15, at 3:30 PM, Ben Trumbull wrote: Running an integrity check can be useful if you have previously gotten a corrupt db error back from fetching or saving, or your app previously crashed, or you have some other active

re: Core Data Autoincrement?

2010-03-15 Thread Ben Trumbull
Is there a way (in a Core Data entity) to make an attribute that's like a relational DB autoincrement field? Or, failing that, does an object of class (or subclass) NSManagedObject inherit a unique UInt32 value that can reliably differentiate it from any other instance being managed

Re: Problem with save as and freed managed object context

2010-03-12 Thread Ben Trumbull
Further information: I have just gone through every place in our code where it makes reference to the managed object context (there's only 90 of them thank goodness), and there is nothing there where we either retain or release a managed object context, or use one in a notification or

re: Core Data Spotlight: Record-Level Indexing : Issues?

2010-03-12 Thread Ben Trumbull
On Mac OS X v10.6 and later, for non-document-based programs, you can create Spotlight indexes where each record is indexed individually. [1] I interpret this to mean that users can get results for my app's records in their Spotlight searches, the way they get Safari bookmarks and Address

re: Trouble with core data and Save As

2010-03-02 Thread Ben Trumbull
I'm having another look at an issue I posted about a couple of weeks ago, where Save As was causing an error. At the time, I was using a custom managed object context. I have now reverted to a standard managed object context. I do not create or release this managed object context anywhere -

Re: NSNull vs nil in NSManagedObject setValue: v forKey: k

2010-03-01 Thread Ben Trumbull
NSManagedObject* obj; // gets created somehow [obj setValue: nil forKey: @bar]; // succeeds where NSDictionary fails [obj setValue: [NSNull null] forKey: @bar]; // fails where NSDictionary succeeds so - this is conceptually buggy thinking and the thoughtful developer could be forgiven

re: Core Data 10.5 Mapping error 134140. Troubleshooting, Value Expressions?

2010-02-28 Thread Ben Trumbull
In my latest model revision, I added a relationship between existing entities. The value of nil would be fine, so I typed 'nil' in for Value Expression on each end. The compiler swallowed it OK. Also, I added a Date attribute, which I would like to default to NSDistantFuture, but since I

re: Core Data design question: receiving KVO notifications of partially mutated objects

2009-11-02 Thread Ben Trumbull
What is considered best practice when it comes to mutating many properties of a managed object, specifically with regard to KVO observers getting notified before all mutations are finished? This is a problem intrinsic to the design of KVO. KVO is all about fine grained per property

re: Unable to open Core Data documents

2009-11-02 Thread Ben Trumbull
I recently recompiled an existing project for 10.6. I made no changes to the code. However, the resulting binary is no longer able to open older files created by this program. The error message is: The document „Budget.drachma‰ could not be opened. drachma cannot open files of this

Re: Could not merge data-error on save in a single moc app

2009-11-02 Thread Ben Trumbull
On 29.10.2009, at 20:05, Ben Trumbull wrote: I get a Could not merge changes-error on save in a single moc app (*). The docs state this is a problem of a multi-moc setup: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreData/Articles/cdTroubleshooting.html Yes

Re: Help debugging Dangling reference to an invalid object. Core Data error

2009-11-02 Thread Ben Trumbull
On 10/29/09 5:23 PM, Ben Trumbull said: Even if I do [scene addTargetsWeak:[scene targetsWeak]] I get the error. Does this make any sense to anyone? The only caveat is you cannot change relationships from within - awakeFromFetch. This is documented: Ben, This is something I know

Re: Core Data design question: receiving KVO notifications of partially mutated objects

2009-11-02 Thread Ben Trumbull
If your issue is that drawing or recalculation is occurring too frequently after KVO changes, you can consider coalescing and deferring the observers' actions instead of performing them synchronously. This can be valuable even for less complex KVO issues. You could also refactor the 3

re: EXC_BAD_ACCESS when migrating a store, but only sometimes...

2009-10-29 Thread Ben Trumbull
I've come across a rather perplexing problem which is driving me nuts. I'm attempting to migrate a core data SQLite store to the current model version, and most of the time it works fine. However, sometimes I get an EXC_BAD_ACCESS in the following stack: objc_assign_strongCast + 19

re: Could not merge data-error on save in a single moc app

2009-10-29 Thread Ben Trumbull
I get a Could not merge changes-error on save in a single moc app (*). The docs state this is a problem of a multi-moc setup: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreData/Articles/cdTroubleshooting.html Yes, the MOC you are saving refers to data that has

Re: Help debugging Dangling reference to an invalid object. Core Data error

2009-10-29 Thread Ben Trumbull
On Oct 29, 2009, at 16:55 , Sean McBride wrote: On 10/22/09 4:59 PM, Melissa J. Turner said: I have an entity 'Scene' with a to-many relationship to an entity 'Target'. The inverse relationship is also to-many. Both relationships are optional and the delete rule for both sides is

re: Core Data: Undoing Cut-Paste, Drag-Drop between documents

2009-10-27 Thread Ben Trumbull
Although some users might expect that the employee moves from Document 2 back to Document 1, that does not happen. Because each document has its own managed object context and own undo manager, because Document 2 is active, the employee disappears from there. But order to make it

re: Search on Core data Table issue?

2009-10-22 Thread Ben Trumbull
Not sure if this is the right place (I am sure someone will let me know if it is not) I have a iPhone application that has a UITable view that is backed by core data. I want to perform a reducing search so that only the items starting with the characters entered into the search bar are shown.

re: Help debugging Dangling reference to an invalid object. Core Data error

2009-10-22 Thread Ben Trumbull
Core Data is giving me a validation error when I try to save a document after making a simple change. I have an entity 'Scene' with a to-many relationship to an entity 'Target'. The inverse relationship is also to-many. Both relationships are optional and the delete rule for both sides is

Re: odd behavior with NSError?

2009-10-16 Thread Ben Trumbull
(response is pedantic for the purposes of the archive :) even more better flaming pedanticism! On Oct 15, 2009, at 10:41 PM, Nathan Vander Wilt wrote: Ouch. So the following pattern is incorrect? Yes; it is incorrect. NSError* internalError = nil; (void)[foo somethingReturningBool:bar

re: Default Core Data errors

2009-10-14 Thread Ben Trumbull
Do you check, and at least assert, if any API that has an NSError** parameter returns one ? (typically a return value of NO or nil). For Core Data, you'll always want to check adding a store to the coordinator, saving, and fetching. For your documented based app, the NSDocument APIs can

re: CoreData could not fulfill a fault after Save As

2009-10-14 Thread Ben Trumbull
The short description is this - I have a document based CoreData app. I can carefully craft a set of data. I then open the document, select a particular record, and do a Save As. This works fine. But when I select a second record, I get errors that CoreData could not fulfill a fault. If I quit

Re: Default Core Data errors

2009-10-14 Thread Ben Trumbull
On Oct 14, 2009, at 12:21 PM, Rick Mann wrote: In the simplest case, I don't create any entities. I don't override any of NSPersistentDocument's persistence-related methods. I just save the new untitled document, then try to re-open it. You can override the methods declared in

Re: More Core Data Questions

2009-10-13 Thread Ben Trumbull
On Oct 13, 2009, at 3:17 AM, Jon Hull wrote: You don't need proxies or NSProxy for this. You can just use a delegate. Off the cuff, I might consider implementing a protocol on your immutable objects for methods like currentLocation and currentPlayer which vector through a semi-global

Saving for iPhone - Can core data handle this?

2009-10-12 Thread Ben Trumbull
Jon, Your question is a bit amorphous. Can Core Data do something like this ? Sure. May it require adjusting things to fit into its architecture ? Possibly. I have a game project for the iPhone which has a rather complicated object graph Well, it would probably only take a few

Re: CoreData Bug? (SQLite vs XML) + isolated reproducible case

2009-10-12 Thread Ben Trumbull
Thanks for the test project. However, reviewing and fixing all compiler warnings is likely to make development a significantly less frustrating experience. We've taken to fixing (nearly) all compiler warnings, even ones we know are harmless, so we can easily find the new ones that likely

re: More Core Data Questions

2009-10-12 Thread Ben Trumbull
Ok, let me ask some more specific questions and see if that gets a response... Feel free to respond if you only know the answer to 1 or 2 of these. 1) Can I count on a to-many relationship keeping the order of the managedObjects it points to? The order is very important in this case, and I

Re: More Core Data Questions

2009-10-12 Thread Ben Trumbull
The project is a game engine which has 2 graphs. The first is a tree of events that represent the story. Each event in the story is an immutable object, and there is a special event which represents a series of events to run in order and one which represents branches that the player has to

re: [iPhone} Exception After Creating First Object

2009-10-10 Thread Ben Trumbull
I got a couple of private messages about breakpoints and stacktraces, which, of course, I had done before I posted my question. That's how I discovered that [mod processPendingChanges] led to an exception when adding to an empty database table. I learned a little more about the exception. It

Re: CoreData async fetch request

2009-10-08 Thread Ben Trumbull
On Oct 7, 2009, at 10:12 PM, David Melgar wrote: Hello, I didn't mean to state threads as a requirement when I said async, I just meant some way to get partial results, such as a call to a delegate I referenced in the previous note. And I'm certainly not seeking complexity of threads if

Re: Core Data KVO with To-Many Relationships

2009-10-08 Thread Ben Trumbull
Since my previous post, I have been able to get the functionality I was hoping for with the following code in my Department subclass. I would greatly appreciate some feedback as to whether this is an appropriate way to implement the functionality or if there is a more efficient or cleaner way.

Re: CoreData async fetch request

2009-10-08 Thread Ben Trumbull
On Oct 8, 2009, at 8:28 PM, David Melgar wrote: I read a little on ICU and now understand that sqlite by default does not handle case insensitive unicode. Is there an easy way to make sqlite use ICU on the Mac, or do I have to build it myself with ICU enabled? Probably the easiest thing

Re: CoreData async fetch request

2009-10-07 Thread Ben Trumbull
an excellent feature request. Please file it with bugreport.apple.com But if you take my advice and make the query run in 1.8s instead of 180s, how important is this to you ? - Ben On Oct 6, 2009, at 4:08 AM, Ben Trumbull wrote: On Oct 5, 2009, at 7:00 PM, enki1...@gmail.com wrote: I am

Re: CoreData async fetch request

2009-10-06 Thread Ben Trumbull
the same, or be stuck with ASCII. Regardless, you'll need to make your searches eligible for an index. The DerivedProperty example shows how to do that. - Ben Thanks On Oct 5, 2009 7:14pm, Ben Trumbull trumb...@apple.com wrote: Is there a way to do an asynchronous fetch request

re: CoreData async fetch request

2009-10-05 Thread Ben Trumbull
Is there a way to do an asynchronous fetch request against Core data returning partial results? That depends on whether it's the query part that's expensive (e.g. WHERE clause with complex text searching and table scans) or simply the quantity of the row data that's your problem. For the

re: whether to use core data...

2009-10-05 Thread Ben Trumbull
But the Core Data documentation starts like this: ... Core Data is not an entry-level technology. ... You should not simply try to read [The Core Data Programming Guide] straight through to understand Core Data. ... Do not attempt the NSPersistentDocument Core Data Tutorial unless or until you

Re: Strange Core Data save behaviour (required relationship nil... when it is set the line before saving)

2009-09-30 Thread Ben Trumbull
On Sep 30, 2009, at 12:56 AM, Luke Evans wrote: Well, I'm more than happy to file a bug, as it has been tricky to figure out (and I would probably still be at it without your interjection). There are several ways to frame the problem of course: it could be a documentation bug... things

Re: Strange Core Data save behaviour (required relationship nil... when it is set the line before saving)

2009-09-30 Thread Ben Trumbull
I don't think anyone has cared enough to file a bug on this. I don't get it. There's an open manhole in the street with the manhole cover lying right next to it, and the problem is that no one cared enough to call the Department of Works to complain? This has come up 3 or 4 times in about

re: Strange Core Data save behaviour (required relationship nil... when it is set the line before saving)

2009-09-29 Thread Ben Trumbull
Now, I have some code that changes the value of the 'B enumeration value' that A is using. This does the following: 1. Create a new instance of the B subentity that represents the value we want (in the same MOC as A) 2. Delete the old B object that A was pointing to, i.e. [moc deleteObject:B];

Re: Strange Core Data save behaviour (required relationship nil... when it is set the line before saving)

2009-09-29 Thread Ben Trumbull
, you've just improved my humour by several degrees ;-) -- Luke On 2009-09-29, at 3:59 PM, Ben Trumbull wrote: Now, I have some code that changes the value of the 'B enumeration value' that A is using. This does the following: 1. Create a new instance of the B subentity that represents the value

re: Snow Leopard, core data, read only and multiple threads

2009-09-27 Thread Ben Trumbull
I've got an app that worked on Leopard. I ported it to Snow Leopard SDK 10.6, and now it works on Snow Leopard, but it doesn't work correctly on Leopard anymore. I haven't changed anything that ought to affect this. What doesn't work ? It's an app with a foreground gui that writes an XML

re: Re: [__NSFastEnumerationEnumerator nextObject] unexpectedly not very fast!

2009-09-25 Thread Ben Trumbull
In summary, the existence of fast enumeration does nothing for existing enumeration technologies and if you have to support 10.4 (as I do) you simply can't use it unless you fork your code. My solution, in the few cases where performance is paramount, has been to essentially roll my own fast

re: Core Data: relationship 'too large' when saving

2009-09-24 Thread Ben Trumbull
I am encountering an error that I have not seen before. While saving in a NSManagedObjectContext I am encountering an error that reports a to-many relationship as 'too large'. This relationship has ~10,000 members but each member is relatively simple consisting of a few short strings and

Re: Core Data memory not freed after reset

2009-09-22 Thread Ben Trumbull
On Sep 22, 2009, at 8:54 AM, Sean McBride wrote: On 9/21/09 4:21 PM, Ben Trumbull said: If you're using an NSArrayController in Entity mode, you can turn on Use Lazy Fetching. You'll want to disable auto-rearrange content. Ben, May I ask, why turn off 'auto-rearrange content

re: Core Data memory not freed after reset

2009-09-21 Thread Ben Trumbull
in my SQLite backed Core Data app, a search action fetches from a large number of objects (1.000.000) only to show them in a table. When the user exits search mode (search string empty), I'd like to free the managed objects to restore the app's normal memory footprint. I do that by resetting the

Re: Core Data memory not freed after reset

2009-09-21 Thread Ben Trumbull
Core Data has (or, I should say, had, since I haven't investigated the behavior in Snow Leopard) its own internal in-memory cache of object and attribute data, which means that, up to a point, data from a persistent store is in memory twice. AFAICT there's no way of unloading or controlling this

re: Core Data threading fun

2009-09-21 Thread Ben Trumbull
I have a server app that responds to network requests, making use of a Core Data database to serve responses. Some requests update the database. I have chosen to allow requests to arrive on multiple threads, and intend for these threads to use Core Data directly. In keeping with Core Data's doc

Re: How to create subentity object inheriting from superentity object in core data

2009-09-17 Thread Ben Trumbull
On Sep 17, 2009, at 9:21 AM, Leon Starr wrote: So, going back to my example, (and the part everyone disagrees with!) I still don't get it. More importantly, my objc compiler doesn't get it! In the model, Auto.license is properly inherited by the Sedan and Truck subentities. No trouble

re: Core Data: strange keypath problem

2009-09-17 Thread Ben Trumbull
Here is the console output: 2009-09-17 12:44:17.659 myAppSales[11094:a0f] Application DMXRef: janTotal starting... 2009-09-17 12:44:17.660 myAppSales[11094:a0f] Application DMXRef: janTotal predicates set. 2009-09-17 12:44:17.662 myAppSales[11094:a0f] anotherArray count = 117 2009-09-17

re: How to create subentity object inheriting from superentity object in core data

2009-09-16 Thread Ben Trumbull
I've got a generalization in my core data model with entities named A, B, C let's say where A is a super class with subentities B and C. A is not abstract, so if I create an A NSManagedObject, I need to create and relate a single B or C subclass object. How do I make this happen? I can create

Re: How to create subentity object inheriting from superentity object in core data

2009-09-16 Thread Ben Trumbull
Okay, my understanding, then, is that the inheritance is just in the model - makes sense. If you subclass NSManagedObjects for the parent and child entities, you need to explicitly declare and synthesize (dynamically) all common properties you want to access at lower levels of the hierarchy (at

re: CoreData multiple contexts and threads

2009-09-13 Thread Ben Trumbull
Hello, I have a stream of data (some messages) from a socket and I need to save it in a CoreData db. I would to optimize this thing by using more than a managedobjectcontext for each N messages arrived. The problem is that I need to link these message between (parent/childs). How can I check if a

re: CoreData Bug? (SQLite vs XML)

2009-09-13 Thread Ben Trumbull
I've been trying to track down a bug and it *seems* that it might be CoreData's fault (I highly doubt it but there's a small chance). I have the following configuration: - A base class, let's call it Base - A subclass of Base, let's call it Subclass Subclass has a to-many relationship to Base.

re: Core Data Manual Migration

2009-09-11 Thread Ben Trumbull
The process fails here and the log then contains the following: An error occured while manually migrating document: Error Domain=NSCocoaErrorDomain Code=134110 UserInfo=0xf336960 An error occured during persistent store migration. [6871:813] Error: { reason = Can't add source store; } There

re: Is Core Data appropriate to my task?

2009-09-10 Thread Ben Trumbull
Gwynne, I have an application that manages two kinds of data: A singular file that contains a large amount of rarely changed (but not invariant) data, and documents that contain one root object's worth of information that connects to the singular data set in a very large number of places; the

Re: Is Core Data appropriate to my task?

2009-09-10 Thread Ben Trumbull
I don't see this as being equivelant at all. Extending the example, let's say the company with these Employees has as its directors several discriminating unfair people, and thus an Employee from any given Planet gets a salary adjustment based on that Planet. The obvious place for this data is

Re: Is Core Data appropriate to my task?

2009-09-10 Thread Ben Trumbull
Before anything else, let me say thank you for a clear, concise, and very helpful set of answers to my questions; I was expecting rather more of a struggle for understanding :). my pleasure. On Sep 10, 2009, at 5:04 PM, Ben Trumbull wrote: The inverse relationship from Planet to Employee

Re: Core Data fetch with to-many relationship

2009-09-09 Thread Ben Trumbull
When I log the test fetch results: NSArray *testFetchResults = [managedObjectContext fetchObjectsForEntityName:@Owner withPredicate:[NSString stringWithFormat:@ANY books.name like 'myPrefix*']]; NSLog([[(Owner *)[testFetchResults objectAtIndex:0] books] valueForKey:@name]); I get the following

Re: KVO can be unsafe in -init?

2009-09-09 Thread Ben Trumbull
On 08/09/2009, at 12:36 AM, John Chang wrote: Hi all, Question: is it unsafe for some reason to be adding yourself as a KVO observer during -init? We have a singleton with an -init that looks something like this: - (id)init { if ((self = [super init])) { _foo = [[NSMutableDictionary alloc]

Re: watch changes to any properties on an object

2009-09-03 Thread Ben Trumbull
Well, @dynamic doesn't have anything to do with KVO. It's just storage and accessors for properties. Core Data knows when non- dynamic modeled properties change too. It sets a dirty flag, just as you would have to. Most of that happens in -willChangeValueForKey:. Unfortunately,

Re: Core Data dog-slow when using first time after boot

2009-09-03 Thread Ben Trumbull
On Sep 3, 2009, at 4:49 AM, Ruotger Skupin wrote: Since it's not a many to many, you can perform the prefetching effectively by hand using a fetch request to preload the relevant destination rows with an IN query based on the data you initially fetched for the source entity. You

Re: watch changes to any properties on an object

2009-09-03 Thread Ben Trumbull
On Sep 3, 2009, at 12:14, Alexander Cohen wrote: Ah, ok, this is more like what i wanted to hear! :) I understand how @dynamic works, but how to I get to funnel all calls to @dynamic properties to the same call such as setValue:forKey: or something like that where i can parse the key and update

re: Correct way to have nil undo manager in Core Data document?

2009-08-29 Thread Ben Trumbull
Well, I've got a background worker process which opens an NSPersistenDocument. Since it has no undo capability, I want to set it to nil as recommended. (I have other reasons for not wanting an undo manager scurrying around.) But the document doesn't like having nil undo manager. When I ask

re: Core Data Predicate Builder - comparing dates

2009-08-29 Thread Ben Trumbull
I have a Core Data entity that has a dateCreated and a dateModified - both NSDates in the object files. I'd like to construct a predicate that will retrieve all records where a record's dateModified is greater than that record's dateCreated. Its deceptively easy to setup something that looks

re: Curious about $SUBST_VARS within a SUBQUERY of a fetch request template

2009-08-29 Thread Ben Trumbull
I just created a fetch request template in my MOM that looked like: SUBQUERY(platformInfos, $each, $each.platformName == $PLATFORM_NAME)@count == 0 I then looked up the template in the code and attempted to use it in the usual manner with:

  1   2   3   >