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

123
Views
No se puede asignar un valor de tipo (también conocido como 'Array<Dictionary<String, Style>>') a (también conocido como 'Dictionary<String, Style>')

Este es mi código:

 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 }

Nota: var stylesMap: [[StyleID: Style]]? ¿Cómo creo un diccionario de stylesArray ? (Creo que Map en javascript es un diccionario en Swift)

Estoy tratando de portar el código JavaScript a Swift. A continuación se muestra el código javascript:

 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

Si desea solo el primer elemento, como se menciona en los comentarios, puede reemplazar la siguiente línea:

 objectNode.stylesMap = stylesArray

con:

 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!