Closed pwightman closed 11 years ago
When does didChangeField
get called in ActiveRecord.m, is there some sort of observer observing changes to each property in the model? I stuck a breakpoint in there and didChangeField
never gets called, so changedFields
never gets instantiated, which causes [changedFields count]
to return nil here: http://d.pr/i/vSL1/5Fn3RvRm
Investigating some more to see if I can pinpoint a fix.
Hm... There is magic :) I don't use any observers and it works (almost), I've tried to use KVO, but it work very slow, so I forced to abandon them.
At the new version I've implemented custom observer, so it works as needed. But I should implement few more features before release.
I've had similar issues with saving - seems fairly sporadic. I've had luck with manually calling the setValue: forKey: method for the ActiveRecord instance.
Loving iActiveRecord, Alex!
I'm getting this same issue.
changedFields
and return early (and therefore does nothing)setValue: forKey:
passes the update SQL into sqlite3_exec
, gets no errors, but does not update the databaseGuys, you can try new version from master
branch, but it is still unstable and not compatible with current stable version.
So far the difference is only in properties:
stable
branch uses @synthesize
and ignored_properties
macro, but the new version uses @dynamic
for database columns, all @synthesize
'd properties would ignored.
cheers, I'll give master
a try
So broken in 1.3.2?
yeah, you'll definitely want to use latest. Don't know what's been added since, but last I played (165e4c6e80a1cfc85408d44cd675c0c1078705ff) it was pretty stable.
So there is no way to get this working on 1.3.2?
I noticed this in my own project, and made a small project to demonstrate that you can download here: http://d.pr/f/1EQq/1NHJehlq
It's using the version in cocoapods. The main code is essentially this:
Which prints out the following:
Notice that
model.title
is an empty string after retrieving it from the DB. If you put a print statement inside theexecuteSqlQuery
method, it never executes an UPDATE. My guess is this has to do with tracking dirty/changed attributes, but it's hard to say for sure.