Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
Cannot assign value of type (aka 'Array<Dictionary<String, Style>>') to (aka 'Dictionary<String, Style>')

This is my code:

override func style(node: Node) throws -> StyleNode {
    guard let objectNode = try super.style(node: node) as? StyleNode
    else {
      throw UEErrors.unrecoverableError(message: "Could not create Node")
    }

    guard let stylesArray = node.stylesMap else {
      throw UEErrors.unrecoverableError(message: "stylesMap is missing")
    }
    objectNode.stylesMap = stylesArray //error : Cannot assign value of type '[[StyleID : Style]]' (aka 'Array<Dictionary<String, Style>>') to type '[StyleID : Style]' (aka 'Dictionary<String, Style>')
    return objectNode
  }

Note: var stylesMap: [[StyleID: Style]]? How do I create a dictionary of stylesArray? (I think Map in javascript is dictionary in swift)

I'm, trying to port javascript code to swift. Below is javascript code:

static style(
    node: Node,
    baseProps: BaseConstructorProperties,
  ): this {
    const stylesArray = assertNonNull(
      Node?.stylesMap,
      'stylesMap is missing',
    );

    return new this({
      ...baseProps,
      stylesMap: new Map(stylesArray),
    });
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you want just the first item, as mentioned in the comments, you can replace the following line:

objectNode.stylesMap = stylesArray

with:

guard let first = stylesArray.first else {
  throw UEErrors.unrecoverableError(message: "No items")
}
objectNode.stylesMap = first
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!