Hi,
I have this code here, and I am really struggling with using SwiftUI and an MVVM architecture to display data from this NASA API. I want to take the image URL passes through the JSON and display it. I Found this article that shows how to use the SDWebView Swift package, and I would like to use this package to take the image URL that comes out of the JSON and display that image.
However, I am not sure how to setup my View Model... I made this app a bit ago that parses JSONs and puts them in a table, but when it seems like you have to setup your view model differently for creating a table compared to just displaying an image? Do any of you have any tips or resources I can look at ? thanks
Post
Replies
Boosts
Views
Activity
here is my code on GitHub that has screen shots of what I have now and what I am trying to accomplish.
I followed this YouTube video: https://www.youtube.com/watch?v=0H78ktM97yU to come up with what I have now.
Using data from this api, https://jsonplaceholder.typicode.com/todos I have built a table via importing the data from a model.swift file and the built in JSON parser. Now I am trying to let user view more information about the title they selected. This api has data that looks like this:
[
{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
},
{
"userId": 1,
"id": 2,
"title": "quis ut nam facilis et officia qui",
"completed": false
},
...cont...
]
Right now I think the way to get to where I want to be is by adding in a 'cocoatouch class' view controller, and adding in code to this file to alter the label field. However, I am not sure what kinda code to add into this cocoatouch class view controller titled 'title_details_ViewController.swift'. I know that it has to connect to my file titled 'Model' somehow...
Thanks in advanced <3
Hello, This is for a JP Morgan Chase Take home quiz for an iOS developer role.
There are two parts to this test:
take this JSON data with NYC high school SAT scores (https://data.cityofnewyork.us/resource/f9bf-2cp4.json) and put it into a table.
when a user clicks on a school from this table they should be able to view statistics on the SAT scores about said school (SAT statistics in the same JSON call from part 1).
to accomplish part one of this test I used this YouTube video titled "How To Pass API Data To TableView Cells In Swift IOS" (https://www.youtube.com/watch?v=0H78ktM97yU&t=646s) to make a table with all the schools in the JSON file. Here is my code that is the same as this video except with the API of the schools instead of the API from the YouTube video.
to accomplish the second part of this test I found this YouTube video (https://www.youtube.com/watch?v=samoIVHg6yQ&t=533s) on expandable tables. This is where I am struggling though. I figured it wouldn't be hard to take the code from this YouTube video and implement it into the code I made from the YouTube video I used for part one.... but... I was soooo wrong. Here is the code from this YouTube video
My first thought on how to implement the code from the "Creating Expandable TableView Cells (Collapsable) - Xcode 12, Swift 5, iOS Development 2022" YouTube video into the code I made from the "How To Pass API Data To TableView Cells In Swift IOS" was to edit the Model.swift file in my code. However, when I do that I get an error from Xcode saying "Return from initializer without initializing all stored properties" cuz I added in the 'init' subclass (I think that is what it is called). Then I tried to edit the model again and I didn't get an error, but this time my emulator just doesn't show any code...?
Does anyone have any advice on how to get this code to work? In case this is confusing, here is an image of what I have now and what I am trying to accomplish in my readme along with the prompt I got from JPMC.
(also-- I already got rejected for this role 2 weeks ago bc I failed the test, but now I am trying to figure out how to solve it anyways for my own learning development, so you're not helping me 'cheat' by helping me with this. I just want to learn how to get APIs to work cuz I know how important that is for iOS jobs)
PS: sorry for the wonky formatting Apple forums don't allow you to post YouTube videos or JSON files so I had to get crafty.