Git Product home page Git Product logo

Comments (2)

fealebenpae avatar fealebenpae commented on June 4, 2024

Right now the bridge will convert an Array to an NSArray implicitly, but that's because I can recognize the Array exotic object. I can project the Map exotic object as NSDictionary the same way, but from what I gather Maps are not what you're after.

Type-coercing exotic objects is simple, but it becomes tricky to do correctly for plain JavaScript objects. I can't guess the purpose of an object - is it array-like, is it map-like, is it javascript-framework-du-jour's idea of a date, and so on. That's why there's no implicit conversion to NSDictionary today.

What I can do is convert an Object to a NSDictionary only when the target type is explicitly NSDictionary. That is to say, if a native function or method accepts CFDictionaryRef or NSDictionary. Would that work for you?

from ios-jsc.

fealebenpae avatar fealebenpae commented on June 4, 2024

The runtime can now wrap JavaScript values in NSArray and NSDictionary instances:

  • When converting to id
    • Values of the JavaScript Array exotic object will be wrapped as NSArray
    • Values of the JavaScript Map exotic object will be wrapped as NSDictionary
  • When converting to NSArray or NSDictionary
    • Values of the JavaScript Array exotic object and plain JavaScript objects with a length property and indexed properties will be wrapped as NSArray
    • Values of the JavaScript Map exotic object and plain JavaScript objects will be wrapped as NSDictionary

Native NSArray and NSDictionary instances will still be exposed as Wrapper exotic objects to JavaScript, same as before.

from ios-jsc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.