xcode
Assignment 03: Translator App
For this assignment, you will build an iOS app that will be a very simple English-to-Spanish language translator. (Note: If you desire, you can use a language other than Spanish for the translated words.)
Project Setup Requirements
Create a new Xcode project using the Single View Application template as follows:
Product Name: LastName-Translator (e.g. Ibrahim-Translator) Organization Name: Your Name (e.g.Ibrahim) Organization Identifier: com.yourfirstandlastname (e.g. com.Ibrahim) Language: Swift
Do NOT check any checkboxes
App Specifications
Description of User Interface:
· The app will contain only one scene, using the MainStoryboard.storyboard. This scene must include the following view objects: o Two labels (UILabel) §One of the labels should be placed near the top of the screen and should be used to create a title for the app §The second label will be used to display the translated word. Since this label will require interaction with the view controller, you must create an outlet for it. o A text field (UITextField) §The text field will be used by the user to type in an English word. It should be placed above the label where the translated word will appear. Use either the placeholder attribute of the text field or an additional label to provide instructions to the user (e.g. Enter an English word). Since this text field will require user input, you must create an outlet connection for it. In addition, you must verify that the on-screen keyboard will be properly dismissed using techniques previously learned in class. o A button (UIButton) §The button should be easy to identify and click and should have a descriptive command written on it (i.e. Translate). Since this button will need event handling, you must create an action connection for it.
· In addition to the required elements listed above, the user interface may optionally contain other items to make it look professional if you desire to learn to add any (e.g. image, etc.). The user interface should have a clean, balanced, and professional look (you can choose the title, fonts, and colors).
• Use Auto Layout to ensure that the view objects will appear in an aligned and organized fashion regardless of the screen size. Test your layout before continuing and adjust constraints manually if needed.
Description of the Data Model:
· Use a pair of parallel arrays to hold the English words and their Spanish (or other language) equivalents.
· You must include the following translations (others can be added at your discretion):
o phone -> telefono
o dog -> perro o sad -> triste o happy -> feliz o crocodile -> cocodrilo
(Note: If you choose a language other than Spanish, you must still include these same English words with their correct translations, for testing purposes.)
Description of App Functionality:
· Store the words in the arrays as all lowercase letters (this will aid in the word matching process because case sensitivity could be a factor).
· When a user types an English word into the text box, you should search the English word array and if a match is found, display the match from the Spanish (or other language) array in the label on screen. Note that you should convert the word that the user types in to all lowercase letters before doing the comparison.
· If no match is found, display an appropriate error message (e.g. Sorry, no translation available).
· If no text is entered into the text box when the button is clicked, display an appropriate error message (e.g. Please enter an English word to translate).
· Make sure that you add the appropriate code to ensure that the on-screen keyboard is dismissed when the user clicks the Done button.
· The app should function with no syntax (build) errors and no runtime errors. Tips
· To search an array, you should implement a for-in loop
· The .lowercased() method can be used on a String value to convert it to all lowercase letters.
· Remember that you can use the break statement to stop a loop
· Remember that the text property of a text field or label can be accessed using dot notation: self.myLabel.text
· Remember that if a text field is going to be empty at runtime, you may need to reference it as an optional (?) or an implicitly unwrapped optional (!) in Swift (e.g. self.myTextField.text! )
· You should use all Powerpoints and previous examples to assist you with this app, as well as the online documentation from the assigned Swift reading Development Process to Follow
• Follow the 6-Step Process for Building an App from last week’s notes.