1616
1717#import < Foundation/Foundation.h>
1818#import < UIKit/UIKit.h>
19+
20+ /* JSCore not supported on iOS version < 7.0 */
21+ #ifdef __IPHONE_7_0
1922#import < JavaScriptCore/JavaScriptCore.h>
23+ #endif
2024
2125#include < core.h>
2226
@@ -230,6 +234,9 @@ inline void MCBrowserRunBlockOnMainFiber(void (^p_block)(void))
230234
231235 if (m_delegate != nil )
232236 [m_delegate release ];
237+
238+ if (m_js_handler_list != nil )
239+ [m_js_handler_list release ];
233240 });
234241}
235242
@@ -312,23 +319,34 @@ inline void MCBrowserRunBlockOnMainFiber(void (^p_block)(void))
312319
313320 if (m_js_handlers != nil )
314321 {
315- [m_js_handler_list release ];
316- m_js_handler_list = nil ;
317-
318322 MCCStringFree (m_js_handlers);
319323 m_js_handlers = nil ;
320324 }
321325
322326 m_js_handlers = t_handlers;
323327 t_handlers = nil ;
324328
325- if (m_js_handlers != nil )
326- m_js_handler_list = [[[NSString stringWithCString: m_js_handlers encoding: NSUTF8StringEncoding] componentsSeparatedByString: @" \n " ] retain ];
327-
328- MCBrowserRunBlockOnMainFiber (^{
329- SyncJavaScriptHandlers (m_js_handler_list);
330- });
329+ /* JSCore not supported on iOS version < 7.0 */
330+ #ifdef __IPHONE_7_0
331+
332+ if (NSClassFromString (@" JSContext" ))
333+ {
334+ if (m_js_handlers != nil )
335+ {
336+ if (m_js_handler_list != nil )
337+ [m_js_handler_list release ];
338+ m_js_handler_list = nil ;
339+
340+ m_js_handler_list = [[[NSString stringWithCString: m_js_handlers encoding: NSUTF8StringEncoding] componentsSeparatedByString: @" \n " ] retain ];
341+ }
342+
343+ MCBrowserRunBlockOnMainFiber (^{
344+ SyncJavaScriptHandlers (m_js_handler_list);
345+ });
346+ }
331347
348+ #endif
349+
332350 return true ;
333351}
334352
@@ -337,6 +355,9 @@ inline void MCBrowserRunBlockOnMainFiber(void (^p_block)(void))
337355 bool t_success;
338356 t_success = true ;
339357
358+ /* JSCore not supported on iOS version < 7.0 */
359+ #ifdef __IPHONE_7_0
360+
340361 // get js context for browser
341362 JSContext *t_context;
342363 t_context = nil ;
@@ -376,6 +397,8 @@ inline void MCBrowserRunBlockOnMainFiber(void (^p_block)(void))
376397 }
377398 }
378399
400+ #endif
401+
379402 return t_success;
380403}
381404
0 commit comments