Java Objective-C AOP

Java

Use an AOP library or byte-code engineering (BCEL, cglib, asm, etc) to create a sub-class on the fly. Any calls to the getter or setter of an observed property notifies any attached observers.

Objective-C

This is similar to Java - uses isa swizzling to create a sub-class on the fly. Any calls to an observed property notifies attached observers. Interestingly, in Objective-C we can swizzle back to the original class without the wrapped property methods, if all observers are removed. Whereas in Java a class is typically loaded once, so you're always notifying a (possibly empty) set of observers.

posted @ 2019-09-23 14:01  zzfx  阅读(159)  评论(0编辑  收藏  举报