Files
LayaNative2.0/Conch/build/wkwebview/proj.ios/WKWebview/Test.mm
T
2020-11-11 16:17:13 +08:00

22 lines
825 B
Plaintext

#import <Foundation/Foundation.h>
#import "Test.h"
#import <LayaWKWebview.h>
@implementation Test
+(void)test:(NSString*)json
{
NSError* error = nil;
NSData* jsonData = [json dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary* dict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
NSLog(@"OC: %@", [dict objectForKey:@"value"]);
{
NSDictionary* dic = [NSDictionary dictionaryWithObject:@"Hello JS!" forKey:@"value"];
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dic options:0 error:&error];
NSString* jsonStr = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
[[LayaWKWebview GetLayaWKWebview] callbackToJSWithClass:self.class methodName:@"test:" ret:jsonStr];
}
}
@end