[MacRuby-devel] Need to Write Core Data Accessors in MacRuby?

Shannon Love techzen at me.com
Mon Jun 27 15:45:24 PDT 2011


Howdy,

I've Core Data a lot in Objective-c and now I am trying to use it in MacRuby. It occurs to me that I might need to create the to-many relationship accessors just like you have to do in Objective-C. 

To clarify: Suppose I have a data model that models a file structure and which looks like this:

Folder{
  name:string
  parent<<-->Folder.subFolders
  subFolders<-->>Folder.parent
  files<-->>File.folder
}
File{
  name:string
  folder<<-->Folder.file
}

In Objective-C, I would normally have methods in the `Folder` class that would look like:

addSubFoldersObject:
removeSubFoldersObject:
addSubFoldersObjects:
removeSubFoldersObjects:

The methods themselves would use look something like:

- (void)addSubFoldersObject:(FetchedPropertyExtractor *)value {    
    NSSet *changedObjects = [[NSSet alloc] initWithObjects:&value count:1];
    [self willChangeValueForKey:@"SubFolders" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
    [[self primitiveValueForKey:@"SubFolders"] addObject:value];
    [self didChangeValueForKey:@"SubFolders" withSetMutation:NSKeyValueUnionSetMutation usingObjects:changedObjects];
    [changedObjects release];
}

Do you have to do the same thing in MacRuby or will the normal ruby set operations suffice?

Thanks,
Shannon Love a.k.a TechZen


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110627/903babbd/attachment.html>


More information about the MacRuby-devel mailing list