0

So I am trying to store some info in my NSDictionary and I need to store a CGPoint value. I am trying something like this:

var dict = ["name" : "john", "age" : 20, "coords": (5, 10)]

Doesn't work unfortunately. How do I store it (so I can call it dict["coords"])?

Hemang
  • 26,840
  • 19
  • 119
  • 186
  • See this thread: http://stackoverflow.com/questions/26251678/how-to-convert-cgpoint-in-nsvalue-in-swift –  Jan 01 '15 at 12:05
  • 1
    Why was this question marked as duplicate? The linked question looks different a little, and Mehdi's answer is better than the linked answer for this question. – findall Jan 01 '15 at 12:27

2 Answers2

0

Your problem is that coords is not declared. I guess you meant "coords".

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
-1

You can do something like this :

var dict:[String:Any] = ["name" : "john", "age" : 20, "coords": (5, 10)]

println(dict["coords"])
Mehdi.Sqalli
  • 510
  • 1
  • 5
  • 22