geting error with Dictionary

2019-07-08 07:38发布

     let parameter : Dictionary<String,AnyObject> =  ["action":"add-playlist-item","playlist_id":self.dictPlayList.objectForKey("ID")!,"kod_id":arrayOfID]

error ["action": add-playlist-item, "playlist_id": 166, "kod_id": <_TtCs21_SwiftDeferredNSArray 0x7c615620>( 21, 18 ) ]

_TtCs21_SwiftDeferredNSArray 0x7c615620 what does this error mean??

2条回答
成全新的幸福
2楼-- · 2019-07-08 08:29

Array is a value type and it's not an object, but a struct. So it doesn't conform to AnyObject protocol. Use Any instead of AnyObject. See more details here and here.

查看更多
女痞
3楼-- · 2019-07-08 08:31

Check that you are using JSON parameter encoding, not URL encoding.

You may be having the same problem I was having. I was seeing <_TtCs21_SwiftDeferredNSArray 0x7c615620> appear in my requests too. When I changed to JSON encoding, everything worked. I don't think a dictionary structure like that can be properly URL encoded. I'm not sure how you're actually making the request or I would post code.

查看更多
登录 后发表回答