D
D
deleted-mezhevikin2014-01-11 13:39:08
Objective-C
deleted-mezhevikin, 2014-01-11 13:39:08

Is it possible to track changes to all properties of an NSObject?

Only one way comes to mind: get a list of all properties through runtime and in a loop do addObserver for each field.
Are there other, less artisanal options?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Storozhev, 2014-03-07
@storoj

here, I devoted almost a whole report to this problem at the conference, I hope it will be interesting :)
habrahabr.ru/company/e-Legion/blog/214861

A
Alexey Storozhev, 2014-01-11
@storoj

I guess it depends on what you want to catch. Moreover, not all properties of KV-Observable.
If you want to track changes through setters, you can try to overload methodForSelector: or make method swizzling on it. There, to determine which selector is called, if it starts with "set", then the value is expected to change. We call our handler, we call the original method.
Tell us more about the problem, it will be easier to answer more specifically

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question