iPhone Programming – Spring 2017
Nathan Hull
Assignment 2 – Due: Wednesday, March 1st
In this assignment you will create your first iOS application.
In brief, you will create a program that displays the same product names, descriptions, costs, and num-on-hands which you used in the first assignment, and allows you to increment or decrement the count for any particular product. In addition, each product should have an associated picture.
|
Part One: First, in Xcode, you will be creating a New Project. Choose “File:New Project”, then pick “iOS Application” on the left and from the right panel choose to create a new “Single View Application”.
In all probability, you will probably want to begin to build your project WITHOUT referencing any real data. This will allow you to get your Interface to work without having to worry about how to attach the underlying data structure. So, as a suggestion, you might want the “Backward” button to simply put the string “from Backward” into the first three text fields. It might be amusing to have the “Increment Count” button actually increment the count which is displayed. (Obviously, this will be necessary in Part Two of the assignment).
Next, you will want to create an icon for your project. In order to submit an application to Apple’s App Store, you have to give them a 1024 x 1024 image of your icon. Thus, most projects create their logo in this high resolution, and then reduce it to the various sizes that Apple needs for the App Icon. You should also create a Launch Icon that duplicates your first screen. (See Apple’s Docs on the subject for details). Save your images as PNG graphics, and drop them into Xcode’s images.xcassets folder for your project. (Also, here is a cool Photoshop template which generates the various icon sizes for you. Or, you can also try this online version which takes a 1024×1024 image and converts it for you).
Part Two: After you have gotten your interface to work in some rudimentary fashion, you will turn to the data structure. In this homework, instead of a NSMutableDictionary Object, you will hold your data in a NSMutableArray. This will allow you to access your data ‘in order’. Note that you may want to also carry the named of the associated image for the product. Thus, a possible data set might now look something like this:
Position |
Product |
Description |
Cost |
Num on Hand |
Image |
0 |
iPhone 7 |
Apple’s iPhone 6 minus plug |
769.00 |
2 |
iphone7.png |
1 |
Galaxy Note7 |
Samsung’s Exploding Phone |
850.00 |
90 |
galaxy.png |
2 |
40-inch TV |
Sony’s LED TV |
298.00 |
89 |
tv40.png |
3 |
Kindle Reader |
Amazon’s E-Reader |
79.99 |
200 |
kindle.png |
4 |
Apple Watch |
Series 2 – Aluminum Case |
299.00 |
0 |
apple_watch.png |
There are also many methods for Arrays which are given to you in the Foundation Framework. For example, one method is Apple’s definition of addObject:
— (void)addObject:(id)anObject
In our book, “Programming in Objective-C” by Stephen Kochan, the author gives the following example of this method:
[primes addObject: [NSNumber numberWithInteger:2] ];