0

So for a project I am doing for school, we need to decode some model objects using objective-c and others using swift.

I am trying to decode the json as an array of multiple sol detail objects. It is able to decode the name and total_photos keys, but when it gets to the photos: dictionary it crashes and is unable to decode. Any guidance towards a solution with this would be much appreciated.

Mars Rover API JSON

MarsRover Model Object

LSISoldetails model object

pawello2222
  • 46,897
  • 22
  • 145
  • 209
  • I believe you need to make your objective-c class encodable/decodable. I know how to do this in swift, but I am not sure on how to do it in Objective-C – Jason F Jul 29 '20 at 22:27
  • can you show us your interface for LSISolDetails – Ol Sen Jul 29 '20 at 22:37

1 Answers1

0

Solution

I have figured out what I needed to do, so basically I needed to decode each dictionary individually, different from swift where you can use codable to decode a nested json array, in objective c apparently you have to decode them individually.

  • even worse. plenty amount of possibilities to decode json. https://stackoverflow.com/questions/5547311/how-do-i-parse-json-with-objective-c – Ol Sen Jul 29 '20 at 23:28