|
From: Rupert B. <rup...@fr...> - 2005-11-07 19:00:39
|
After looking at CoreData, and getting stuck at chapter 4 of the
tutorial, I have moved to SyncServices.
I picked up the SimpleStickies tutorial, used the complete (step 3)
source code of the tutorial to replace the Note Objective C class by
a Note.rb : quite easy, I just had to adapt the recent kvc_wrapper
suggestion and came up with :
# accessor for keys defined in Cocoa, for _representation
def kvc_wrapper_representation(*keys)
keys.each do |key|
class_eval <<-EOE_KVC_WRAPPER_REPRESENTATION,__FILE__,__LINE__+1
def #{key}
@_representation.valueForKey("#{key}")
end
def #{key}=(val)
self.willChangeValueForKey("#{key}")
@_representation.setValue_forKey(val, "#{key}")
self.didChangeValueForKey("#{key}")
end
EOE_KVC_WRAPPER_REPRESENTATION
end
end
because the Note class takes its stuff from the _representation
attribute.
I quickly created new setters called setCreateDate, setOriginX etc.
from createDate=, originX=, etc.
Before these changes, I ran the app in full Objective C, saved a few
Notes, and synced them.
Switching to the rubified-Notes, the app will not read them to
display them : it complains that
2005-11-07 19:55:36.494 SimpleStickies[782] Exception syncing:
NSUnknownKeyException, reason [<Note 0x651130> takeValue:forKey:]:
attempt to assign value to unknown key: 'primaryKey'.
This class does not have an instance variable of the name primaryKey
or _primaryKey, nor a method of the name setPrimaryKey, or
_setPrimaryKey
This is strange since dumping the instance_methods of Note shows that
all the expected methods are there :
setCreateDate
createDate
createDate=
etc.
primaryKey
primaryKey=
setPrimaryKey
etc.
So, do you think that SyncServices are using some route which is
bypassing our kvc_wrapper mechanism to reach the primaryKey
"attribute" and getter and setter ?
Rup
|