Reputation: 6937
I want to access properties and call methods of an Objective-C object that was returned to JavaScript host as property of exposed object ([windowScriptObject setValue:self forKey:@"a"]
):
- (id) valueForUndefinedKey:(NSString*) key {
if ( [key isEqualToString:@"b"] ) {
MyObject* obj = [ [ MyObject alloc ] init ];
return obj;
}
return Nil;
}
In Javascript I want to be able to do the following:
// a is already exposed Objective-C object
var b = a.b; // reference to myObject
var c = a.b.c; // myObject.c
var d = a.b.d(); // [ myObject d ]
Upvotes: 1
Views: 898
Reputation: 299265
MyObject
needs to implement +isSelectorExcludedFromWebScript:
and/or +isKeyExcludedFromWebScript:
. By default, Javascript is not allowed to access Objective-C methods; you have to explicitly permit it.
Are you seeing some other symptom beyond that?
For more information, see Using Objective-C From Javascript.
Upvotes: 1