So far all the examples I can find are direct binding between Core Data and NSArrayController. That means each NSArrayController maps exactly one entity.
Is there a way to customize what’s get populated into the NSArrayController?
For example, I have two entities:
FileMetaData
ID
FileName
FileSize
Owner(relationship m..1 to SystemUser)
SystemUser
ID
FirstName
LastName
Files(relationship 1..m to FileMetaData)
I have one NSArrayController to populate a tableview that has two column, one is “FileName”, and the other one is “UserName”. UserName comes from FirstName + Lastname in SystemUser entity. The NSArrayController is set to bind with FileMetaData.
What is the best way to do this? Thanks.
One way to easily get a
UserNameproperty (FirstName+LastName) is to define a category on theSystemUserclass with aUserNamemethod that returns theFirstNameandLastNameproperties duly concatenated.Then in your various bindings you can bind to the
UserNameproperty. Typed directly into the browser, so not tested, aUISupport(or any other name) categorySystemUsercould look like this:In order for the bindings to work if the
FirstNameorLastNameproperties change, you might want to implement this method, too:Finally, for completeness, you can declare your new-fangled read-only property in the header file: