Is there a way to use NSBlock as a property that is changeable in JavaScript?
@protocol ExportingUser <NSObject, JSExport>
@property (nonatomic, copy) void (^changedName) (void);
@property (nonatomic) NSString* name;
@end
I am trying to call changedName from Obj-C, a function whose definition originates from JavaScript. For example:
user.name = "Peyman"; // this will update the name property in Obj-C.
user.changedName = function() { console.log("yay"); } // but this does not work
I am aware of using JSValue's callWithArguments method, but I would prefer an alternate solution if available.
Edit: Upon further consideration, it seems that the callWithArguments method may not be suitable. This is because objects bound to Objective-C classes are not extendable in JavaScript, meaning any new additions would be ignored.