├── OC与JS交互之JavaScriptCore.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcuserdata │ │ └── user.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── user.xcuserdatad │ └── xcschemes │ ├── OC与JS交互之JavaScriptCore.xcscheme │ └── xcschememanagement.plist ├── OC与JS交互之JavaScriptCore ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m ├── index.html └── main.m └── README.md /OC与JS交互之JavaScriptCore.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | CE9947031D65B4B800F38608 /* index.html in Resources */ = {isa = PBXBuildFile; fileRef = CE9947021D65B4B800F38608 /* index.html */; }; 11 | CECE0E431D659819007B7FE4 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = CECE0E421D659819007B7FE4 /* main.m */; }; 12 | CECE0E461D659819007B7FE4 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = CECE0E451D659819007B7FE4 /* AppDelegate.m */; }; 13 | CECE0E491D659819007B7FE4 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = CECE0E481D659819007B7FE4 /* ViewController.m */; }; 14 | CECE0E4C1D659819007B7FE4 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CECE0E4A1D659819007B7FE4 /* Main.storyboard */; }; 15 | CECE0E4E1D659819007B7FE4 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CECE0E4D1D659819007B7FE4 /* Assets.xcassets */; }; 16 | CECE0E511D659819007B7FE4 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CECE0E4F1D659819007B7FE4 /* LaunchScreen.storyboard */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | CE9947021D65B4B800F38608 /* index.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = index.html; sourceTree = ""; }; 21 | CECE0E3E1D659819007B7FE4 /* OC与JS交互之JavaScriptCore.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "OC与JS交互之JavaScriptCore.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | CECE0E421D659819007B7FE4 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 23 | CECE0E441D659819007B7FE4 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 24 | CECE0E451D659819007B7FE4 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 25 | CECE0E471D659819007B7FE4 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 26 | CECE0E481D659819007B7FE4 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 27 | CECE0E4B1D659819007B7FE4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 28 | CECE0E4D1D659819007B7FE4 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 29 | CECE0E501D659819007B7FE4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 30 | CECE0E521D659819007B7FE4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | CECE0E3B1D659819007B7FE4 /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | CECE0E351D659819007B7FE4 = { 45 | isa = PBXGroup; 46 | children = ( 47 | CECE0E401D659819007B7FE4 /* OC与JS交互之JavaScriptCore */, 48 | CECE0E3F1D659819007B7FE4 /* Products */, 49 | ); 50 | sourceTree = ""; 51 | }; 52 | CECE0E3F1D659819007B7FE4 /* Products */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | CECE0E3E1D659819007B7FE4 /* OC与JS交互之JavaScriptCore.app */, 56 | ); 57 | name = Products; 58 | sourceTree = ""; 59 | }; 60 | CECE0E401D659819007B7FE4 /* OC与JS交互之JavaScriptCore */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | CE9947021D65B4B800F38608 /* index.html */, 64 | CECE0E441D659819007B7FE4 /* AppDelegate.h */, 65 | CECE0E451D659819007B7FE4 /* AppDelegate.m */, 66 | CECE0E471D659819007B7FE4 /* ViewController.h */, 67 | CECE0E481D659819007B7FE4 /* ViewController.m */, 68 | CECE0E4A1D659819007B7FE4 /* Main.storyboard */, 69 | CECE0E4D1D659819007B7FE4 /* Assets.xcassets */, 70 | CECE0E4F1D659819007B7FE4 /* LaunchScreen.storyboard */, 71 | CECE0E521D659819007B7FE4 /* Info.plist */, 72 | CECE0E411D659819007B7FE4 /* Supporting Files */, 73 | ); 74 | path = "OC与JS交互之JavaScriptCore"; 75 | sourceTree = ""; 76 | }; 77 | CECE0E411D659819007B7FE4 /* Supporting Files */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | CECE0E421D659819007B7FE4 /* main.m */, 81 | ); 82 | name = "Supporting Files"; 83 | sourceTree = ""; 84 | }; 85 | /* End PBXGroup section */ 86 | 87 | /* Begin PBXNativeTarget section */ 88 | CECE0E3D1D659819007B7FE4 /* OC与JS交互之JavaScriptCore */ = { 89 | isa = PBXNativeTarget; 90 | buildConfigurationList = CECE0E551D659819007B7FE4 /* Build configuration list for PBXNativeTarget "OC与JS交互之JavaScriptCore" */; 91 | buildPhases = ( 92 | CECE0E3A1D659819007B7FE4 /* Sources */, 93 | CECE0E3B1D659819007B7FE4 /* Frameworks */, 94 | CECE0E3C1D659819007B7FE4 /* Resources */, 95 | ); 96 | buildRules = ( 97 | ); 98 | dependencies = ( 99 | ); 100 | name = "OC与JS交互之JavaScriptCore"; 101 | productName = "OC与JS交互之JavaScriptCore"; 102 | productReference = CECE0E3E1D659819007B7FE4 /* OC与JS交互之JavaScriptCore.app */; 103 | productType = "com.apple.product-type.application"; 104 | }; 105 | /* End PBXNativeTarget section */ 106 | 107 | /* Begin PBXProject section */ 108 | CECE0E361D659819007B7FE4 /* Project object */ = { 109 | isa = PBXProject; 110 | attributes = { 111 | LastUpgradeCheck = 0730; 112 | ORGANIZATIONNAME = rrcc; 113 | TargetAttributes = { 114 | CECE0E3D1D659819007B7FE4 = { 115 | CreatedOnToolsVersion = 7.3.1; 116 | }; 117 | }; 118 | }; 119 | buildConfigurationList = CECE0E391D659819007B7FE4 /* Build configuration list for PBXProject "OC与JS交互之JavaScriptCore" */; 120 | compatibilityVersion = "Xcode 3.2"; 121 | developmentRegion = English; 122 | hasScannedForEncodings = 0; 123 | knownRegions = ( 124 | en, 125 | Base, 126 | ); 127 | mainGroup = CECE0E351D659819007B7FE4; 128 | productRefGroup = CECE0E3F1D659819007B7FE4 /* Products */; 129 | projectDirPath = ""; 130 | projectRoot = ""; 131 | targets = ( 132 | CECE0E3D1D659819007B7FE4 /* OC与JS交互之JavaScriptCore */, 133 | ); 134 | }; 135 | /* End PBXProject section */ 136 | 137 | /* Begin PBXResourcesBuildPhase section */ 138 | CECE0E3C1D659819007B7FE4 /* Resources */ = { 139 | isa = PBXResourcesBuildPhase; 140 | buildActionMask = 2147483647; 141 | files = ( 142 | CECE0E511D659819007B7FE4 /* LaunchScreen.storyboard in Resources */, 143 | CE9947031D65B4B800F38608 /* index.html in Resources */, 144 | CECE0E4E1D659819007B7FE4 /* Assets.xcassets in Resources */, 145 | CECE0E4C1D659819007B7FE4 /* Main.storyboard in Resources */, 146 | ); 147 | runOnlyForDeploymentPostprocessing = 0; 148 | }; 149 | /* End PBXResourcesBuildPhase section */ 150 | 151 | /* Begin PBXSourcesBuildPhase section */ 152 | CECE0E3A1D659819007B7FE4 /* Sources */ = { 153 | isa = PBXSourcesBuildPhase; 154 | buildActionMask = 2147483647; 155 | files = ( 156 | CECE0E491D659819007B7FE4 /* ViewController.m in Sources */, 157 | CECE0E461D659819007B7FE4 /* AppDelegate.m in Sources */, 158 | CECE0E431D659819007B7FE4 /* main.m in Sources */, 159 | ); 160 | runOnlyForDeploymentPostprocessing = 0; 161 | }; 162 | /* End PBXSourcesBuildPhase section */ 163 | 164 | /* Begin PBXVariantGroup section */ 165 | CECE0E4A1D659819007B7FE4 /* Main.storyboard */ = { 166 | isa = PBXVariantGroup; 167 | children = ( 168 | CECE0E4B1D659819007B7FE4 /* Base */, 169 | ); 170 | name = Main.storyboard; 171 | sourceTree = ""; 172 | }; 173 | CECE0E4F1D659819007B7FE4 /* LaunchScreen.storyboard */ = { 174 | isa = PBXVariantGroup; 175 | children = ( 176 | CECE0E501D659819007B7FE4 /* Base */, 177 | ); 178 | name = LaunchScreen.storyboard; 179 | sourceTree = ""; 180 | }; 181 | /* End PBXVariantGroup section */ 182 | 183 | /* Begin XCBuildConfiguration section */ 184 | CECE0E531D659819007B7FE4 /* Debug */ = { 185 | isa = XCBuildConfiguration; 186 | buildSettings = { 187 | ALWAYS_SEARCH_USER_PATHS = NO; 188 | CLANG_ANALYZER_NONNULL = YES; 189 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 190 | CLANG_CXX_LIBRARY = "libc++"; 191 | CLANG_ENABLE_MODULES = YES; 192 | CLANG_ENABLE_OBJC_ARC = YES; 193 | CLANG_WARN_BOOL_CONVERSION = YES; 194 | CLANG_WARN_CONSTANT_CONVERSION = YES; 195 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 196 | CLANG_WARN_EMPTY_BODY = YES; 197 | CLANG_WARN_ENUM_CONVERSION = YES; 198 | CLANG_WARN_INT_CONVERSION = YES; 199 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 200 | CLANG_WARN_UNREACHABLE_CODE = YES; 201 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 202 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 203 | COPY_PHASE_STRIP = NO; 204 | DEBUG_INFORMATION_FORMAT = dwarf; 205 | ENABLE_STRICT_OBJC_MSGSEND = YES; 206 | ENABLE_TESTABILITY = YES; 207 | GCC_C_LANGUAGE_STANDARD = gnu99; 208 | GCC_DYNAMIC_NO_PIC = NO; 209 | GCC_NO_COMMON_BLOCKS = YES; 210 | GCC_OPTIMIZATION_LEVEL = 0; 211 | GCC_PREPROCESSOR_DEFINITIONS = ( 212 | "DEBUG=1", 213 | "$(inherited)", 214 | ); 215 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 216 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 217 | GCC_WARN_UNDECLARED_SELECTOR = YES; 218 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 219 | GCC_WARN_UNUSED_FUNCTION = YES; 220 | GCC_WARN_UNUSED_VARIABLE = YES; 221 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 222 | MTL_ENABLE_DEBUG_INFO = YES; 223 | ONLY_ACTIVE_ARCH = YES; 224 | SDKROOT = iphoneos; 225 | }; 226 | name = Debug; 227 | }; 228 | CECE0E541D659819007B7FE4 /* Release */ = { 229 | isa = XCBuildConfiguration; 230 | buildSettings = { 231 | ALWAYS_SEARCH_USER_PATHS = NO; 232 | CLANG_ANALYZER_NONNULL = YES; 233 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 234 | CLANG_CXX_LIBRARY = "libc++"; 235 | CLANG_ENABLE_MODULES = YES; 236 | CLANG_ENABLE_OBJC_ARC = YES; 237 | CLANG_WARN_BOOL_CONVERSION = YES; 238 | CLANG_WARN_CONSTANT_CONVERSION = YES; 239 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 240 | CLANG_WARN_EMPTY_BODY = YES; 241 | CLANG_WARN_ENUM_CONVERSION = YES; 242 | CLANG_WARN_INT_CONVERSION = YES; 243 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 244 | CLANG_WARN_UNREACHABLE_CODE = YES; 245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 246 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 247 | COPY_PHASE_STRIP = NO; 248 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 249 | ENABLE_NS_ASSERTIONS = NO; 250 | ENABLE_STRICT_OBJC_MSGSEND = YES; 251 | GCC_C_LANGUAGE_STANDARD = gnu99; 252 | GCC_NO_COMMON_BLOCKS = YES; 253 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 254 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 255 | GCC_WARN_UNDECLARED_SELECTOR = YES; 256 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 257 | GCC_WARN_UNUSED_FUNCTION = YES; 258 | GCC_WARN_UNUSED_VARIABLE = YES; 259 | IPHONEOS_DEPLOYMENT_TARGET = 9.3; 260 | MTL_ENABLE_DEBUG_INFO = NO; 261 | SDKROOT = iphoneos; 262 | VALIDATE_PRODUCT = YES; 263 | }; 264 | name = Release; 265 | }; 266 | CECE0E561D659819007B7FE4 /* Debug */ = { 267 | isa = XCBuildConfiguration; 268 | buildSettings = { 269 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 270 | INFOPLIST_FILE = "OC与JS交互之JavaScriptCore/Info.plist"; 271 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 272 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 273 | PRODUCT_BUNDLE_IDENTIFIER = "com.renrencaichang.OC-JS---JavaScriptCore"; 274 | PRODUCT_NAME = "$(TARGET_NAME)"; 275 | }; 276 | name = Debug; 277 | }; 278 | CECE0E571D659819007B7FE4 /* Release */ = { 279 | isa = XCBuildConfiguration; 280 | buildSettings = { 281 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 282 | INFOPLIST_FILE = "OC与JS交互之JavaScriptCore/Info.plist"; 283 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 284 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 285 | PRODUCT_BUNDLE_IDENTIFIER = "com.renrencaichang.OC-JS---JavaScriptCore"; 286 | PRODUCT_NAME = "$(TARGET_NAME)"; 287 | }; 288 | name = Release; 289 | }; 290 | /* End XCBuildConfiguration section */ 291 | 292 | /* Begin XCConfigurationList section */ 293 | CECE0E391D659819007B7FE4 /* Build configuration list for PBXProject "OC与JS交互之JavaScriptCore" */ = { 294 | isa = XCConfigurationList; 295 | buildConfigurations = ( 296 | CECE0E531D659819007B7FE4 /* Debug */, 297 | CECE0E541D659819007B7FE4 /* Release */, 298 | ); 299 | defaultConfigurationIsVisible = 0; 300 | defaultConfigurationName = Release; 301 | }; 302 | CECE0E551D659819007B7FE4 /* Build configuration list for PBXNativeTarget "OC与JS交互之JavaScriptCore" */ = { 303 | isa = XCConfigurationList; 304 | buildConfigurations = ( 305 | CECE0E561D659819007B7FE4 /* Debug */, 306 | CECE0E571D659819007B7FE4 /* Release */, 307 | ); 308 | defaultConfigurationIsVisible = 0; 309 | defaultConfigurationName = Release; 310 | }; 311 | /* End XCConfigurationList section */ 312 | }; 313 | rootObject = CECE0E361D659819007B7FE4 /* Project object */; 314 | } 315 | -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MarkStray/OC-JS-JavaScriptCore/eca1cce3f258a1059b2fd8e7e61be3f9dd571364/OC与JS交互之JavaScriptCore.xcodeproj/project.xcworkspace/xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/OC与JS交互之JavaScriptCore.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore.xcodeproj/xcuserdata/user.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | OC与JS交互之JavaScriptCore.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | CECE0E3D1D659819007B7FE4 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // OC与JS交互之JavaScriptCore 4 | // 5 | // Created by user on 16/8/18. 6 | // Copyright © 2016年 rrcc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // OC与JS交互之JavaScriptCore 4 | // 5 | // Created by user on 16/8/18. 6 | // Copyright © 2016年 rrcc. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 36 | 47 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // OC与JS交互之JavaScriptCore 4 | // 5 | // Created by user on 16/8/18. 6 | // Copyright © 2016年 rrcc. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // OC与JS交互之JavaScriptCore 4 | // 5 | // Created by user on 16/8/18. 6 | // Copyright © 2016年 rrcc. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import 11 | 12 | @interface ViewController () 13 | 14 | @property (weak, nonatomic) IBOutlet UIWebView *webView; 15 | 16 | @property (nonatomic, strong) JSContext *jsContext; 17 | 18 | @end 19 | 20 | @implementation ViewController 21 | 22 | - (void)viewDidLoad { 23 | [super viewDidLoad]; 24 | 25 | //初始化webView 26 | NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]; 27 | NSURL *baseURL = [[NSBundle mainBundle] bundleURL]; 28 | [self.webView loadHTMLString:[NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil] baseURL:baseURL]; 29 | 30 | //初始化JSContext 31 | self.jsContext = [self.webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"]; 32 | 33 | self.jsContext.exceptionHandler = ^(JSContext *context, JSValue *exceptionValue) { 34 | context.exception = exceptionValue; 35 | NSLog(@"异常捕获信息:%@", exceptionValue); 36 | }; 37 | 38 | __block typeof(self) weakSelf = self; 39 | //JS调用OC方法列表 40 | self.jsContext[@"showMobile"] = ^ { 41 | dispatch_async(dispatch_get_main_queue(), ^{ 42 | [weakSelf showMsg:@"我是下面的小红 手机号是:18870707070"]; 43 | }); 44 | }; 45 | 46 | self.jsContext[@"showName"] = ^ (NSString *name) { 47 | dispatch_async(dispatch_get_main_queue(), ^{ 48 | NSString *info = [NSString stringWithFormat:@"你好 %@, 很高兴见到你",name]; 49 | [weakSelf showMsg:info]; 50 | }); 51 | }; 52 | 53 | void (^_showSendMsg) (NSString *num, NSString *msg) = ^ (NSString *num, NSString *msg) { 54 | dispatch_async(dispatch_get_main_queue(), ^{ 55 | NSString *info = [NSString stringWithFormat:@"这是我的手机号: %@, %@ !!",num,msg]; 56 | [self showMsg:info]; 57 | }); 58 | }; 59 | 60 | [self.jsContext setObject:_showSendMsg forKeyedSubscript:@"showSendMsg"]; 61 | } 62 | 63 | - (void)showMsg:(NSString *)msg { 64 | [[[UIAlertView alloc] initWithTitle:nil message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil] show]; 65 | } 66 | 67 | //OC调用JS方法列表 68 | - (IBAction)btnClick:(UIButton *)sender { 69 | if (sender.tag == 123) { 70 | //使用jsContext 71 | [self.jsContext evaluateScript:@"alertMobile()"]; 72 | } 73 | 74 | if (sender.tag == 234) { 75 | //使用webView 76 | [self.webView stringByEvaluatingJavaScriptFromString:@"alertName('小红')"]; 77 | } 78 | 79 | if (sender.tag == 345) { 80 | //使用jsValue 81 | JSValue *jsValue = [self.jsContext objectForKeyedSubscript:@"alertSendMsg"]; 82 | [jsValue callWithArguments:@[@"18870707070",@"周末爬山真是件愉快的事情"]]; 83 | } 84 | 85 | } 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 小黄 6 | 9 | 10 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |

46 | 47 |
48 | 49 |
50 |

51 | 52 | 53 |
54 | 55 |
56 |
57 | 58 |
59 | 60 |
61 |
62 | 63 |
64 | 65 |
66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /OC与JS交互之JavaScriptCore/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // OC与JS交互之JavaScriptCore 4 | // 5 | // Created by user on 16/8/18. 6 | // Copyright © 2016年 rrcc. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OC-JS-JavaScriptCore --------------------------------------------------------------------------------