0

I am trying to create an array which elements are dictionaries which keys are strings and values are AnyObject. This is my code:

var informationOfRows: Array<Dictionary<String, AnyObject>> = [
        ["title": "Mis Promos", "icon": FontAwesome.Money, "segue": "myPromoSegue"],
        ["title": "Mis Marcas", "icon": FontAwesome.Briefcase, "segue": "myBrandSegue"],
        ["title": "Editar Perfil", "icon": FontAwesome.Edit, "segue": "editUserProfileSegue"],
        ["title": "Invitar Amigo", "icon": FontAwesome.EnvelopeO, "segue": "inviteFriendSegue"],
        ["title": "Quejas y Sugerencias", "icon": FontAwesome.LightbulbO, "segue": "suggestionSegue"]
    ]

However, I am getting an error message that states: Type of expression is ambiguous without more context.

How can I solve this issue?

Thanks in advance

P.S.: Fontawesome is a library which contains a bunch of icons.

4
  • Can you add the declaration for FontAwesome here? Commented Sep 8, 2015 at 17:20
  • It is just an enumeration which definition is public enum FontAwesome: String. Commented Sep 8, 2015 at 17:26
  • 1
    There comes your problem: String is a value type, not object type, so it doesn't conform to AnyObject. Swift 1.2 gave a better error message than 2.0 on this. Change your dictionary to <String, Any> instead. Commented Sep 8, 2015 at 17:31
  • 1
    Thank you so much, it worked, if you want you can provide an answer, and I can mark it as valid. :) Commented Sep 8, 2015 at 17:33

1 Answer 1

1

Your FontAwesome is an enum of type String:

public enum FontAwesome: String { ... }

String is a value type, not object type, so it doesn't conform to AnyObject. Swift 1.2 gave a better error message than 2.0 on this. Change your dictionary to <String, Any> instead:

var informationOfRows: Array<Dictionary<String, Any>> = ...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.