Jacob Smith Jacob Smith - 7 months ago 101
Swift Question

How to remove an item from JSON array in Swift (using SwiftyJSON)

Pretty simple and straightforward question.

I have a jsonArray, and i want to delete an item by index. How do I do that?

I tried using the solution from here:
https://github.com/SwiftyJSON/SwiftyJSON/issues/439

Like this:

jsonArray[row]["Likers"].array!.dictionaryObject?.removeValueForKey(index)


But I got this error:

value of type json has no member dictionaryObject

Answer

you just use

yourJsonArry.removeAtIndex(2) 

Hear you just pass the index that you want to remove items

Comments