Debugging Help for iOS App

Hello. I am building a gardening app for iOS. I’m trying to make a call to an API endpoint but something is going wrong somewhere. Please help!

Please describe in more detail what’s “wrong” specifically.

what endpoint? what API? what’s your code look like? what’s the error? To be able to help we have to know what’s “wrong somewhere”

Hello. So I have a new problem on my hands. How do I figure out all the possible endpoints of the following API?

The documentation you linked says “API Reference” from there, this link Trefle documentation - Reference | Trefle documentation shows all the endpoints

You can see it on the left, and then clicking the different sections it shows what kind of request like GET, POST, etc and then you can see what parameters are required and what the response should look like

Thank you! So, I’ve run into a new problem. I can’t figure out what the data type of null fields might be.

It’s likely that the documentation is referring to data items that do not have a value and in the example returns from the API call to Plants they show that as NULL… ie:

"id": 273225,
"common_name": null,
"slug": "senecio-gamolepis",
"scientific_name": "Senecio gamolepis",
"year": 1955,
"bibliography": "Notas Mus. La Plata, Bot. 18(89): 222 (1955)",
"author": "Cabrera",
"status": "accepted",
"rank": "species",
"family_common_name": "Aster family",
"genus_id": 669,
"image_url": null,  // 
"synonyms": [ ],
"genus": "Senecio",
"family": "Asteraceae",
"links": {}

Note that the image_url and common_name is null.

Something to watch out for in these API’s in the documentation is that the properties are declared in snake_case which is an underscore between the words in the property name. In Swift we use camelCase so that means that the first word is all lowercase and each successive word has the first letter capitalised with no spaces or underscores. So image_url from the API will translate to imageUrl in your data model.

We deal with that NULL case in Swift by declaring that property as Optional so that when the json code is decoded into the model you have defined, that field can be “nil”.

The JSON Decoder understands that a property with NULL means that it has no value and requires that the associated property in the data model be declared as Optional.

So in the model it would be declared like this:

..
var commonName: String?
..
..
..
..
var imageUrl: String?
..
..

Are you familiar with JSON code and decoding json?

Yes, sir. Thank you so much! You really helped me!

Hello. I’m back! I am about to put my app onto the App Store. So, I thought I would share some screenshots of my app to give you guys a sneak peak of my app.





I had one question. For “Content Rights”, do I put No?

Also, for my App Store Listing, under App Privacy, under Data Collection, Do I click “Yes, we collect data from this app.” or “No, we do not collect data from this app.”?

Also, I don’t need to submit to TestFlight, do I? That part is totally optional, right?

I’m awaiting approval for my Apple Developer subscription to be able to put my app onto the App Store! It’s taking me longer than I had expected. Please wish me all the very best of a luck!