From e6bdc3d8197910ae380436f85ed55d86f2421d8b Mon Sep 17 00:00:00 2001 From: "pengfei.zhou" Date: Fri, 15 Jul 2022 16:02:22 +0800 Subject: [PATCH] iOS: fix add version judgment for JSTypedArray API --- doric-iOS/Pod/Classes/Engine/JSValue+Doric.mm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/doric-iOS/Pod/Classes/Engine/JSValue+Doric.mm b/doric-iOS/Pod/Classes/Engine/JSValue+Doric.mm index 43c1a17b..1dcc7404 100644 --- a/doric-iOS/Pod/Classes/Engine/JSValue+Doric.mm +++ b/doric-iOS/Pod/Classes/Engine/JSValue+Doric.mm @@ -123,12 +123,14 @@ static id containerValueToObject(JSGlobalContextRef context, JSContainerConverto } JSObjectRef object = JSValueToObject(context, value, 0); - JSTypedArrayType type = JSValueGetTypedArrayType(context, value, NULL); - if (type == kJSTypedArrayTypeArrayBuffer) { - size_t size = JSObjectGetArrayBufferByteLength(context, object, NULL); - void *ptr = JSObjectGetArrayBufferBytesPtr(context, object, NULL); - id primitive = [[NSData alloc] initWithBytesNoCopy:ptr length:size freeWhenDone:NO]; - return {value, primitive, ContainerNone}; + if (@available(iOS 10.0, *)) { + JSTypedArrayType type = JSValueGetTypedArrayType(context, value, NULL); + if (type == kJSTypedArrayTypeArrayBuffer) { + size_t size = JSObjectGetArrayBufferByteLength(context, object, NULL); + void *ptr = JSObjectGetArrayBufferBytesPtr(context, object, NULL); + id primitive = [[NSData alloc] initWithBytesNoCopy:ptr length:size freeWhenDone:NO]; + return {value, primitive, ContainerNone}; + } } if (JSValueIsArray(context, value)) return {object, [NSMutableArray array], ContainerArray};