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, overridi

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 shouldn't

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 my

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 follo

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] in

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 do

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 th

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 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"; } The

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. He

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 the

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 l

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 a

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 12:44:17.6

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 c

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: 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 conte

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 numbers.

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 enum

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 c

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]; 3.

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

2009-09-29 Thread Ben Trumbull
e insights on the above, then that would be great. Regardless, 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 fol

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 are

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 6

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 la

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 al

Re: CoreData async fetch request

2009-10-06 Thread Ben Trumbull
the same order of magnitude. And then, either you'll have to integrate ICU support as Core Data does, and it'll be exactly 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

Re: CoreData async fetch request

2009-10-07 Thread Ben Trumbull
queue, an object which could be read from while being written to in another thread. That would make 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,

Re: CoreData async fetch request

2009-10-07 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-07 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 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 oc

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 minute

re: Core Data with OpenGL

2009-10-12 Thread Ben Trumbull
Consider an application using Core Data and OpenGL. Normally a model object (MVC) has no knowledge of views or controllers for good reasons. but in this case it must draw itself. No, it doesn't must do anything. Views draw themselves, model objects are state, and controllers are intermed

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 need

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: 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

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 the

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 NSPersisten

Re: odd behavior with NSError?

2009-10-15 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 e

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. T

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 sid

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: 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 +

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 tha

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

Re: Core Data not fulfill a fault (now: observer) after Save As

2009-11-02 Thread Ben Trumbull
> On 2009 Oct 14, at 12:47, Jim Thomason wrote: > >> On Wed, Oct 14, 2009 at 2:25 PM, Ben Trumbull >> wrote: >>>> The short description is this - I have a document based CoreData >>>> app. >>>> I can carefully craft a set of data. I t

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 notific

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

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/libr

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 - >> awake

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

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 an

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 Add

Re: Problem with "save as" and freed managed object context

2010-03-14 Thread Ben Trumbull
That particular function is trying to CFRetain the result of -identifier on your store. If you've overridden it, make sure it never returns nil and it always returns the same UUID at least until someone calls -setIdentifier. The UUID should also be set in the store's metadata with the key NSSto

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 poi

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 awakeFrom

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

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 >> cras

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 m

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 atte

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
> disk so there's no 'last writer wins'? > > I am not using 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: > >>&

Re: CoreData database sharing and migration

2010-03-17 Thread Ben Trumbull
ata models? > > - Tobias > > On Mar 17, 2010, at 11:13 PM, Ben Trumbull wrote: > >> >> On Mar 17, 2010, at 2:59 PM, Tobias Jordan wrote: >> >>> Hello Ben, >>> >>> Thanks a lot for responding! My problem is as follows: The database whi

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

2010-03-17 Thread Ben Trumbull
would be nice, though, to have a method that I 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 2

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

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 t

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 { > NSAutorele

Re: CoreData database sharing and migration

2010-03-20 Thread Ben Trumbull
kind enough to explain how Apple frameworks do 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, > Objecti

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 ver

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 "g

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: > > B

Re: NSSortDescriptor and Block

2010-03-24 Thread Ben Trumbull
gain, > Jochen Moeller > > > Am 24.03.2010 um 11:12 schrieb Ben Trumbull: > >>> while experimenting with sorting methods I got a strange error message with >>> -sortDescriptorWithKey:ascending:comparator:. >>> >>> In the following listing (a

re: Creating NSMappingModel programmatically

2010-03-29 Thread Ben Trumbull
> 'm trying to create an NSMappingModel manually between two models, but it's > not working in that no data gets migrated over (I checked with an SQLite > database browser) to the new store, the tables are just empty. > > The source model has one entity Person with two attributes: name and eyeCo

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

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: attribute>] != nil. > > In code, I can simply iterate over the keys, perform the valu

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: 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 store

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 th

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

2010-04-03 Thread Ben Trumbull
ide. > > Dave > > On Apr 2, 2010, at 3:42 PM, Ben Trumbull wrote: > >> NSComparisonPredicate* exprPred = (NSComparisonPredicate*)[NSPredicate >> predicateWithFormat:@"SUBQUERY(self, $key, %...@.$key != nil) == 0", obj]; >> NSExpression* exp

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: > >>

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 ne

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

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 pie

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 n

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: Cant read second table from same sqlite database iphone

2010-04-11 Thread Ben Trumbull
NSString * dbPath = [[[NSBundle mainBundle] resourcePath] > stringByAppendingPathComponent:@"/Database.sql"]; > > DebugLog("dbpath is %s\n",[dbPath UTF8String]); > > //copy the database file to ther users docuement directory > > succ

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 si

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 co

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 anywher

re: Re: Triggering change notifications when modifying custom object ivars in core data app

2009-05-28 Thread Ben Trumbull
Specifically my entity has a 'transformable' attribute for which the values are a custom object class, and this object class has an ivar that is an NSMutableDictionary. The user can modify entries in this dictionary, and I would like this to cause the context to be flagged as dirty and to have th

Re: Triggering change notifications when modifying custom object ivars in core data app

2009-05-28 Thread Ben Trumbull
On May 28, 2009, at 11:59 AM, Rick Hoge wrote: Ben, Quincey, Sean, thanks for the comments. Maybe there are some lower level design issues to rethink. This pattern is usually a flawed model design. If the properties are to be this independently mutable, then there should be a relatio

Re: [Core Data] mergeChangesFromContextDidSaveNotification: and thread safety

2009-05-29 Thread Ben Trumbull
On May 29, 2009, at 2:49 AM, Aurélien Hugelé wrote: Core Data multithreading basic rule is to avoid passing managed objects across threads, and pass objectIDs instead. yup. To "synchronize" 2 mocs from 2 different threads (sharing the same psc), I use mergeChangesFromContextDidSaveNotific

re: SQL store, GC apps, "statement is still active" exception, setReturnsObjectsAsFaults:NO

2009-06-01 Thread Ben Trumbull
Now that 10.5.7 (allegedly) fixes the incompatibilities between the SQL store and GC apps, I have been trying to switch from XML to SQL. Most problems I've fixed, but I'm getting an exception: Yes, 10.5.7 fixes all the known issues with (GC, NSDocument, NSSQLiteStore). The incompatibilitie

re: Cascade Delete won't delete Department in Apple Sample Code

2009-06-23 Thread Ben Trumbull
Core Data documentation [1] describes the Cascade Delete Rule as follows: "Delete the objects at the destination of the relationship. For example, if you delete a department, fire all the employees in that department at the same time." In order to understand another problem, I tried this on thi

  1   2   3   >