A quick note. This lesson is a bit odd and mostly for funsies. It was created by the OG App Dev instructor, Emuel Aldridge, just before Thanksgiving in Fall 2020. Hence the title. Several students mentioned they enjoyed this particular assignment, so it was left in the schedule to provide an opportunity for a little light-hearted exploration before you begin the Final Project in this course. Plus, it’s always helpful to familiarize yourself with form elements!
Description
You are about to download a project that you will need to run in the simulator (not the canvas) in order for it to work. The project has 3 form elements, a text field, a stepper, and a picker, that allow a user to select items and submit them to a website. Right now things are set up for selecting a name, a verb, and a pet, but you can add your own data. Once everything is selected, the user clicks a link which submits everything to a website via a Url String that looks like this: https://nmidev.xyz/db2/telme.php?response=Emuel_likes_hamsters
If you copy and paste that link into a browser you should see a response like this one.The response is generated by a PHP file that reads the url and converts the word response into a variable that equals everything that comes after the = sign in the URL. (FYI, you can edit the URL directly, click refresh and a new statement will appear).
This same PHP file could easily be modified to submit the same values to a database where it then could flow back into your app via a JSON feed. One of the main points of this exercise is to expand your thinking about app development, in that it is not very difficult to move data from an IOS app to the Internet and do something else with it. For this particular exercise, I am using a method on the PHP end known as ‘get’ but it is also possible (although more difficult) to use the ‘post’ method. The big difference is that data submitted by post is hidden, while data from get is visible in the URL string. Enough technical blathering! Here’s the assignment.
- Click here to download the starter project. Take note of the name to get into the proper frame of mind for this exercise :).
- Use YOUR data in place of mine and, hopefully, let your creativity run wild. You can create new arrays or even channel data into your app from an API. If it makes sense, you may want to add additional text fields or some other element (slider, date and color pickers come to mind) to generate data.
- The PHP file that you are submitting to has additional built-in variables that you probably won’t need- I put them in when I was designing this assignment – but they are there if you need them for some reason. Those additional variables, should you need or want them start at “zero” (the actual word zero) and run all the way to “twenty.” To use them you would modify your app so that it submits something like this:
https://nmidev.xyz/db2/telme.php?response=Emuel_likes_hamsters&one=_and_his_students_although_they_are_not_equivalent! - In case you haven’t noticed, the PHP file is setup to convert underscores into non-breaking spaces in html which is why the words are separated when they appear on the page.
That’s it! Have fun with this one and don’t stress too much. I mean this! Once you’re done goofing around with this assignment, feel free to get started on the Final Project!