|
CallingJSFromObjC
Evaling whole files
Evaling a string
Calling a Javascript function
Unboxing resultsThese functions return raw Javascript values (JSValueRef). If you want to get an ObjC out of them, you'll need to unbox it with NSObject* objectFromJavascript = nil;
if (![JSCocoaFFIArgument unboxJSValueRef:jsValueRef toObject:&objectFromJavascript inContext:ctx])
{
// Object was not unboxed correctly
return ...
}
// Use objectIf you expect Javascript values such as Boolean or Number or String, you can use JavascriptCore functions like JSValueToNumber or fromJSValueRef : + (BOOL)fromJSValueRef:(JSValueRef)value inContext:(JSContextRef)ctx withTypeEncoding:(char)typeEncoding withStructureTypeEncoding:(NSString*)structureTypeEncoding fromStorage:(void*)ptr; This function will convert a JSValueRef in a raw C value. Check its source for details. |
► Sign in to add a comment