Problem with NSObjectController key path
Problem with NSObjectController key path
- Subject: Problem with NSObjectController key path
- From: sravan <email@hidden>
- Date: Sat, 16 Apr 2005 12:37:40 +0530
Hi all,
Can we have our own controller key in the key path of the NSObjectController(eg selection), key path like employee.name instead of selection.name. This will be useful for me to maintain two different type of objects like employee, department and i will specify key paths like employee.name and department.name for TextFields and they should show the names of the current employee and department object's name values.
The selection method in the NSObjectController always returning some Proxy object an instance of private class. Does it mean that we have to return proxy object for employee accessor method? If it is so no one can create an instance of private object class ?(is there any method to get an instance)
Is employee.name type of key path binding is wrong ?
What i did is .. (complete source code is in my briefcase {
<x-tad-bigger>http://in.briefcase.yahoo.com/sra1_d } in the shared folder path { Cocoa/</x-tad-bigger><x-tad-bigger>ControllerTest</x-tad-bigger><x-tad-bigger>.zip }</x-tad-bigger>).
I created NSObjectController subclass instance and have accessor methods for employee and department in it. here employee and department are dictionaries with only key 'name' and its value is initialized in awakeFromNib. i specified value key path of the text fields as employee.name and department.name. My text fields are not showing the values present in the dictionaries. i have one action method which will change the values in the dictionaries even then it is not updating.
<x-tad-smaller>
-------------------------------------------------------------
</x-tad-smaller><x-tad-smaller>Code in the </x-tad-smaller>NSObjectController subclass
@implementation MyObjectController
<x-tad-smaller>
- (</x-tad-smaller><x-tad-smaller>void</x-tad-smaller><x-tad-smaller>)awakeFromNib
{
employee = [[NSMutableDictionary alloc] init];
[employee setObject:</x-tad-smaller><x-tad-smaller>@"Sra1"</x-tad-smaller><x-tad-smaller> forKey:</x-tad-smaller><x-tad-smaller>@"name"</x-tad-smaller><x-tad-smaller>];
department = [[NSMutableDictionary alloc] init];
[department setObject:</x-tad-smaller><x-tad-smaller>@"Programming"</x-tad-smaller><x-tad-smaller> forKey:</x-tad-smaller><x-tad-smaller>@"name"</x-tad-smaller><x-tad-smaller>];
}
- (</x-tad-smaller><x-tad-smaller>id</x-tad-smaller><x-tad-smaller>)sender
{
</x-tad-smaller><x-tad-smaller>static</x-tad-smaller><x-tad-smaller> </x-tad-smaller><x-tad-smaller>int</x-tad-smaller><x-tad-smaller> i = </x-tad-smaller><x-tad-smaller>0</x-tad-smaller><x-tad-smaller>;
[employee setObject:[NSString stringWithFormat:</x-tad-smaller><x-tad-smaller>@"sra%d"</x-tad-smaller><x-tad-smaller>,i] forKey:</x-tad-smaller><x-tad-smaller>@"name"</x-tad-smaller><x-tad-smaller>];
[department setObject:[NSString stringWithFormat:</x-tad-smaller><x-tad-smaller>@"Programming%d"</x-tad-smaller><x-tad-smaller>,i] forKey:</x-tad-smaller><x-tad-smaller>@"name"</x-tad-smaller><x-tad-smaller>];
[</x-tad-smaller><x-tad-smaller>self</x-tad-smaller><x-tad-smaller> setEmployee:employee];
[</x-tad-smaller><x-tad-smaller>self</x-tad-smaller><x-tad-smaller> setDepartment:department];
i++;
}
</x-tad-smaller>-- accessor methods for the employee and department
<x-tad-smaller>
</x-tad-smaller>@end
--------------------------------------------------------------------
Sra1
Effigent India PVT Ltd.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden