Skip navigation.
 
mlRe: ADC Core Data article
FROM : Philip Mötteli
DATE : Wed Apr 06 14:47:07 2005

Am 06.04.2005 um 01:14 schrieb Scott Stevenson:
> On Apr 5, 2005, at 2:49 PM, Philip Mötteli wrote:

>>> Each entity definition in a managed object model requires the name
>>> of the entity and the name of the class used at runtime to represent
>>> that entity. By default, the class used is NSManagedObject, but the
>>> class may be either NSManagedObject or a subclass thereof.

>>
>> I read that phrase 5 times. Is that really true? Only subclasses of
>> NSManagedObject get managed persistency from Core Data?

>
> Trying to implement transparent persistence without a persistent
> subclass is.... challenging.


We had it with EOF, including un-/redo.
I wouldn't say, it's challenging. It's a lot of work, but we could even
go much further. We wouldn't even need a model.
Well there's one problem: All the classes, which implement all iVars
just as (e. g. void*) or are based on Core Foundation are a real pain.
Those would have to be treated specially. But at least me, I don't do
such things. And I don't know any third party libraries either, except
Apple's.


> The reason that NSManagedObject is distinct from NSObject, is that
> there are many situations where persistence isn't needed or wanted. 
> You should derive your model objects from NSManagedObject, not every
> object in your apps.


I thought you define that in your model? All the classes, that are in
the model, are entities in the DB.


> Managed objects (among others) actually *store* the attributes and
> relationships ("The NSManagedObject ... acts as a dictionary"): that
> would be one of the main features which needs an extra class.


We had that with EOGenericRecord. But you don't need to subclass this
class in order to get persistency in EOF.


> Just cosnider this: a managed object would have to contain some kind
> of a dictionary to contain the data themselves. Judging by the EOF
> example, there probably would be also a link to its entity descriptor
> (whatever class it is defined by--might be a dictionary, too, if
> simplified enough) to define the data structure. Another link would be
> needed to the object's EOEditingContext -- sorry,
> NSManagedObjectContext :)) -- and so forth.
>
> It would be too much to suppose all these things would be part of
> NSObject, would it not?


How did they do it in EOF? They did manage this information externally
to the object itself.
Even isa swizzling would be another possibility, though I would prefer
not to do that.


> On the other hand, if you don't need all these services and just aim
> for persistence, CoreData aren't what you need: just use an
> NSArchiver, and you get the support for any NSObject :))


I do agree, especially, that I have implemented all the necessary to
save any object transparently that way. But sometimes, when you have
millions or billions of objects, you would prefer letting that be
handled by a DB.


Please correct me, if I'm wrong, but I don't really see, what Core Data
has more to offer than EOF? I see though, that it seems to be a cleaner
and compacter implementation of a part of EOF, by leveraging some new
technologies.

I mean, Apple exploits more and more the rich runtime information, that
ObjC provides. If the implementor of a class doesn't use all the way
(void*) as iVars, everything is there. You just parse that information
and you have all the information, that is needed, in order to save all
the objects to a database (including creating tables and
relationships). So you do not even need a model. For aspect oriented
problems, like observing the mutation of objects (un-/redo) you can use
isa swizzling within an editing context.
In my eyes, we shouldn't have to change the design of our software, in
order to fit it into a specific persistence implementation. If I need
persistency, I should just have to link with an additional library of
choice and then being able to send to any object -saveToFileWithName:
or -saveToDatabase or whatever. Just one supplementary line of code.
Then the whole referenced object graph should be saved (of course on
could implement some mechanisms to exclude certain objects). And that's
all possible. As I already said, I save a whole object graph of any
type of objects to a file without implementing any NSCoding protocol
(actually only one, that works for all objects, except the Procedural
mixin' like Core Foundation and iVars, that are not sufficiently
defined, like (void*), etc.

Related mailsAuthorDate
mlADC Core Data article mmalcolm crawford Apr 5, 17:33
mlRe: ADC Core Data article Philip Mötteli Apr 5, 23:49
mlRe: ADC Core Data article Guy English Apr 6, 00:29
mlRe: ADC Core Data article Scott Stevenson Apr 6, 01:14
mlRe: ADC Core Data article Dustin Voss Apr 6, 02:18
mlRe: ADC Core Data article James Duncan David… Apr 6, 02:27
mlRe: ADC Core Data article Jake Macmullin Apr 6, 02:31
mlRe: ADC Core Data article John C. Randolph Apr 6, 02:55
mlRe: ADC Core Data article James Duncan David… Apr 6, 03:01
mlRe: ADC Core Data article Ondra Cada Apr 6, 04:04
mlRe: ADC Core Data article Will Mason Apr 6, 04:48
mlRe: ADC Core Data article Rogelio M.Serrano… Apr 6, 06:05
mlRe: ADC Core Data article Rogelio M.Serrano… Apr 6, 06:06
mlRe: ADC Core Data article mmalcolm crawford Apr 6, 07:46
mlRe: ADC Core Data article Paul Szego Apr 6, 08:22
mlRe: ADC Core Data article mmalcolm crawford Apr 6, 09:52
mlRe: ADC Core Data article ?????Andre? Apr 6, 09:55
mlRe: ADC Core Data article Ondra Cada Apr 6, 12:21
mlRe: ADC Core Data article oplus Apr 6, 12:32
mlRe: ADC Core Data article Mont Rothstein Apr 6, 12:36
mlRe: ADC Core Data article Philip Mötteli Apr 6, 14:47
mlRe: ADC Core Data article Scott Stevenson Apr 6, 18:00
mlRe: ADC Core Data article mmalcolm crawford Apr 6, 18:39
mlRe: ADC Core Data article Nat! Apr 6, 22:35
mlRe: ADC Core Data article mmalcolm crawford Apr 6, 23:47
mlRe: ADC Core Data article Timothy Reaves Apr 7, 00:25
mlRe: ADC Core Data article mmalcolm crawford Apr 7, 00:50
mlRe: ADC Core Data article Shawn Erickson Apr 7, 01:05
mlRe: ADC Core Data article James Duncan David… Apr 7, 01:28
mlRe: ADC Core Data article Todd Blanchard Apr 7, 06:37
mlRe: ADC Core Data article Todd Blanchard Apr 7, 06:41
mlRe: ADC Core Data article Scott Stevenson Apr 7, 06:59
mlRe: ADC Core Data article Philip Mötteli Apr 7, 08:32
mlRe: ADC Core Data article Marcel Weiher Apr 7, 11:59
mlRe: ADC Core Data article Charlton Wilbur Apr 7, 15:11
mlRe: ADC Core Data article Mike Ferris Apr 7, 16:53
mlRe: ADC Core Data article Marcel Weiher Apr 7, 16:55
mlRe: ADC Core Data article Marco Scheurer Apr 7, 17:55
mlRe: ADC Core Data article Marcel Weiher Apr 7, 19:13
mlRe: ADC Core Data article Scott Stevenson Apr 7, 19:55
mlRe: ADC Core Data article Marcel Weiher Apr 7, 21:03
mlRe: ADC Core Data article Mike R. Manzano Apr 7, 21:21
mlRe: ADC Core Data article Timothy Reaves Apr 7, 22:03
mlRe: ADC Core Data article Evan DiBiase Apr 7, 22:28
mlconstraint satisfaction (was: ADC Core Data article) Marcel Weiher Apr 7, 22:35
mlRe: ADC Core Data article mmalcolm crawford Apr 7, 23:05
mlRe: Re: ADC Core Data article ttempel Apr 8, 01:50
mlRe: ADC Core Data article Paul Szego Apr 8, 11:50
mlRe: ADC Core Data article Johnny Deadman Apr 8, 14:10
mlRe: ADC Core Data article Philippe Mougin Apr 8, 16:52
mlRe: ADC Core Data article Shawn Erickson Apr 8, 17:07
mlRe: ADC Core Data article Shawn Erickson Apr 8, 17:17
mlRe: ADC Core Data article Ralph Scheuer Apr 8, 17:28
mlRe: ADC Core Data article Ralph Scheuer Apr 8, 17:32
mlRe: ADC Core Data article John Brownlow Apr 8, 17:47
mlRe: ADC Core Data article Charlton Wilbur Apr 8, 18:34
mlRe: ADC Core Data article Scott Stevenson Apr 8, 18:43
mlRe: ADC Core Data article Ralph Scheuer Apr 8, 19:03
mlRe: ADC Core Data article Philippe Mougin Apr 8, 20:37
mlRe: ADC Core Data article Scott Ellsworth Apr 8, 21:46
mlRe: ADC Core Data article Scott Ellsworth Apr 8, 21:48
mlRe: ADC Core Data article Evan DiBiase Apr 8, 22:16
mlRe: ADC Core Data article mmalcolm crawford Apr 8, 22:30
mlRe: ADC Core Data article mmalcolm crawford Apr 8, 23:13
mlRe: ADC Core Data article Marcel Weiher Apr 9, 02:20
mlRe: ADC Core Data article Marcel Weiher Apr 9, 02:46
mlRe: ADC Core Data article Scott Ellsworth Apr 9, 09:39
mlRe: ADC Core Data article Marcel Weiher Apr 9, 09:44
mlRe: ADC Core Data article Byron Ellis Apr 9, 10:37
mlRe: ADC Core Data article Marcel Weiher Apr 9, 14:03
mlRe: ADC Core Data article Charlton Wilbur Apr 9, 16:01
mlRe: ADC Core Data article ?????Andre? Apr 9, 18:08
mlRe: ADC Core Data article Scott Stevenson Apr 9, 18:24
mlRe: ADC Core Data article Scott Stevenson Apr 9, 18:27
mlRe: ADC Core Data article Marcel Weiher Apr 10, 00:06
mlRe: ADC Core Data article Marcel Weiher Apr 10, 00:16
mlRe: ADC Core Data article Marcel Weiher Apr 10, 00:38
mlRe: ADC Core Data article ?????Andre? Apr 10, 01:03
mlRe: ADC Core Data article Charlton Wilbur Apr 10, 01:13
mlRe: ADC Core Data article mmalcolm crawford Apr 10, 01:53
mlRe: ADC Core Data article Scott Stevenson Apr 10, 01:58
mlRe: ADC Core Data article Todd Blanchard Apr 10, 08:32
mlRe: ADC Core Data article mmalcolm crawford Apr 10, 08:52
mlModerator: EOT Re: ADC Core Data article mmalcolm crawford Apr 10, 09:25
mlRe: ADC Core Data article PA Apr 10, 12:08
mlRe: ADC Core Data article mmalcolm crawford Apr 30, 10:18