Skip navigation.
 
mlUsing NSArrayController programmatically in library class
FROM : dreamcat7
DATE : Sat Sep 06 15:03:43 2008

Hi
I am extending a library class which is also one of my application's 
model objects. The Library class contains an NSMutableArray of NSData 
which it absolutely needs to perform its tasks. To extend the class i 
must now also hold metadata about each NSData object in the array 
(i.e. the <item> elements in the array now becomes a pair or triple).

Conveniently the Hillegass example is similar. In RaisMan the person 
data is displayed in columns of TableView. (and i would like to have a 
tableview maybe also but thats not the point). I should create a new 
object called person.h that defines each element in the array and 
provides the accessor methods for binding to person.expectedRaise and 
person.Name. Then an NSArrayController can give an array for each 
column of the data. Another common method is to make an NSMutableArray 
of NSMutableDictionaries and then binding the dictionary @"key" to the 
arrayController. Either way achieves such a goal.

But here is the crux of my problem:
The library object (which encloses these array) must keep its 
interface which is a flat array of NSData (and as originally) is used 
on the api side.

Can i store internally the complicated array including the metadata 
and use an NSArrayController to expose only the original NSData part 
of each item?

In other words;
This would be equivalent to saying that person.Name == persons.person 
and person.expectedRaise is a calculated metadata about the person. If 
i wanted to use an array of persons in a payroll department object 
then i would initialise the department with an array of person names, 
and the payroll department would take care of figuring out what the 
expectedRaise should be for each person. Then the payroll department 
would need to have itself an NSArrayController to map an array of 
string objects taken by the initializer to the internal array of 
person objects.

Is anything special required to use the NSArrayController 
programmatically as i shall not be using Interface Builder?

Related mailsAuthorDate
mlUsing NSArrayController programmatically in library class dreamcat7 Sep 6, 15:03
mlRe: Using NSArrayController programmatically in library class dreamcat7 Sep 6, 16:47
mlSOLVED: Using NSArrayController programmatically in library class dreamcat7 Sep 6, 18:57