This document discusses using JavaScriptCore to extend the functionality of apps. It provides an example of using JavaScriptCore to evaluate JavaScript code and access the results. It also outlines how JavaScriptCore maps JavaScript types to Objective-C and Swift types. The document describes how JavaScriptCore creates a virtual machine and handles single-threaded execution. It then shows how to export Swift classes to JavaScript using a protocol. Finally, it lists some ways apps like Paw could leverage JavaScriptCore, such as for code generators, importers, and dynamic values.
16. JSValue
JavaScript Type Objective-C Type Swift Type
string NSString String
boolean BOOL Bool
number
NSNumber
double
int32_t
uint32_t
NSNumber!
Double
Int32
UInt32
Date NSDate Date
Array NSArray [AnyObject]
Object NSDictionary [NSObject : AnyObject]
Object custom type custom type