[baseten-users] Notifications
Tuukka Norri
tuukka.norri at karppinen.fi
Sat Oct 10 00:43:27 EEST 2009
Hi!
I'm sorry we haven't had the chance to reply to your earlier e-mails.
We currently have quite an amount of work. I'll write as soon as
possible.
Michael Ruepp kirjoitti 9.10.2009 kello 15.39:
>> I want to achieve, that when I change something in the Persons
>> Table, that the Group.modified property changes to YES (or
>> whatsoever).
>> I want to achieve that when I change wether preName or lastName,
>> that the name Property changes to "preName_lastName".
>>
>> I thought about ValueTransformers, but arent they just for display
>> purposes?
That's correct.
>> I tried with subclassing of BXManagedObject and put it in the
>> Custom Class Name of the BXSynchronisedArrayController Object in
>> IB, then bind the Value of the respective Column to the function
>> setName, it works occasionally, but when I connect the second Time
>> I get:
>>
>> 08.10.09 12:03:40 FCL_01[32257] Cocoa Bindings: Error accessing
>> value for key path name of object <BXDatabaseObject (0x20021d3a0) pgsql://sunrise-big.local/fuse/public/files?id,n=1
>> fault: 1> (from bound object <NSTableColumn: 0x20009c520>
>> identifier: (null) with object ID 1001 in nib named MainMenu.nib):
>> [<BXDatabaseObject 0x20021d3a0> valueForUndefinedKey:]: this class
>> is not key value coding-compliant for the key name.
I think you need to implement -name as well if you have -setName.
BXDatabaseObject handles various keys by overriding -
valueForUndefinedKey: and -setValue:forUndefinedKey:, but the runtime
can't know this.
Some comments:
>> @interface PersonsBO : BXDatabaseObject {
>>
>> BXDatabaseContext* ctx_delegate_;
You can use BXDatabaseObject's -databaseContext method to get the
context in most situations.
>> - (NSString *)setName {
KVC setters aren't usually supposed to return anything, so the return
type should probably be void.
>> if (self.name != nil) {
...
>> [self setValue:@"untitled" forKey:@"name"];
If you call -valueForKey: or -setValue:forKey: from your custom getter
or setter respectively, you're most likely going to cause infinite
recursion, since the default implementation is going to look for your
custom getters and setters, which are going to call the default
implementation via the methods etc. To resolve this, use
BXDatabaseObject's methods -primitiveValueForKey: and -
setPrimitiveValue:forKey:.
>> [ctx_delegate_ save:&error];
You don't have to pass the double-pointer to an NSError if you want
the context (or its delegate) to handle the error. The default
implementation raises an exception :) but this makes the errors
easier to locate.
>> 2. Code only:
>> I successfully created a BXSynchronisedArrayController in my Model
>> Class (at Init). How can I track the Controller for Object changes
>> which returns me the specific Object, which changed?
...
>> I receive already Notifications, but they just return the
>> BXEntitiyDescription as stated in the Manual. But I need the
>> specific Object to set the Modified BOOL of the specific container
>> Group to YES.
One way to achieve this is to write a subclass of BXDatabaseObject (as
you've already done) and call -addObserver:forKeyPath:options:context:
for the relevant keys in some suitable method, perhaps in -
awakeFromFetch. This would only work for specific key paths, though.
If I remember correctly, there isn't currently a very good way to know
when an object gets changed for a key that isn't known beforehand. If
receiving the notification from the database when the change gets
committed is enough, you can use the kBXUpdateNotification. The
objects IDs will be in the userInfo dictionary. We'll add this to the
manual as soon as possible.
> I found then following in the Interface of BXContainerProxy.h:
BXContainerProxy.h is a private header which should be obvious by its
location in PrivateHeaders :)
--
Best regards,
Tuukka Norri
MK&C
More information about the baseten-users
mailing list