0

I'm trying to increment a value in NSMutableArray when an action is done and it is giving me the following error

Cannot assign to immutable expression of type 'int'.

self.itemsArray[tag][itemType]!![itemType]!!["likeCount"] as! Int = self.itemsArray[tag][itemType]!![itemType]!!["likeCount"] as! Int +1

this was my line of code . And I'm pretty sure thats an Int. I'm trying increment the value present in likeCount.

Please help me.

Thanks.

3
  • 1
    Note: it looks like you should not use dictionaries for your use case. I would rather use arrays of custom structs, for example. Dictionaries with nested values are not the most convenient data structures in Swift. At all. :) Commented Jul 18, 2016 at 14:40
  • Can you give me some tips on how to create custom structs for my JSON data Commented Jul 18, 2016 at 15:05
  • Without knowing your data, I can't give you a tailored example. But have a look at this for starters, it can give you ideas: stackoverflow.com/a/34801548/2227743 Commented Jul 18, 2016 at 15:07

0

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.