Please note, this blog entry is from a previous course. You might want to check out the current one.
Lecture #4 has no demo only theory:
Continue reading “cs193p – Lecture #4 – More Swift and Foundation Frameworks”
![Share on Facebook Facebook](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/facebook.png)
![Share on Twitter twitter](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/twitter.png)
![Share on Reddit reddit](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/reddit.png)
![Pin it with Pinterest pinterest](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/pinterest.png)
![Share on Linkedin linkedin](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/linkedin.png)
![Share on tumblr tumblr](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/tumblr.png)
![Share by email mail](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/16x16/mail.png)
![Share on Facebook Facebook](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/facebook.png)
![Share on Twitter twitter](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/twitter.png)
![Share on Reddit reddit](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/reddit.png)
![Pin it with Pinterest pinterest](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/pinterest.png)
![Share on Linkedin linkedin](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/linkedin.png)
![Share on tumblr tumblr](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/tumblr.png)
![Share by email mail](https://cs193p.m2m.at/wp-content/plugins/social-media-feather/synved-social/image/social/regular/32x32/mail.png)
for the iPhone-Application-Development Course from Stanford University et al
Please note, this blog entry is from a previous course. You might want to check out the current one.
Lecture #4 has no demo only theory:
Continue reading “cs193p – Lecture #4 – More Swift and Foundation Frameworks”
Please note, this blog entry is from a previous course. You might want to check out the current one.
Use Autolayout to make your calculator look good on all different kinds of iPhones in both Portrait and Landscape orientations (don’t worry about iPads for now). Just like we used ctrl-drag to the edges of our scene to position display, you can you ctrl-drag between your UILabels (and/or your C button) to fix their vertical/horizontal spacing relative to each other. Use the blue gridlines! It’s probably a good idea to reset all of your autolayout (via the button in lower right corner), then use ctrl-drag to add constraints to things that are not part of the grid of keypad and operation buttons, then use the buttons in the lower right to lay out those (after you’ve moved them in to place relative to your UILabel(s), etc., using dashed blue lines, of course!).
… which we did already for the previous task …
Please note, this blog entry is from a previous course. You might want to check out the current one.
Change the computed instance variable displayValue to be an Optional Double rather than a Double. Its value should be nil if the contents of display.text cannot be interpreted as a Double (you’ll need to use the documentation to understand the NSNumberFormatter code). Setting its value to nil should clear the display out.
Make the display value an optional. When getting the display value, check first if there is a text, then if the text is a number and return the double value. Otherwise return nil. When setting the display value, check if it is nil. If not set the text label to the value otherwise to zero.
Continue reading “cs193p – Project #1 Assignment #1 Extra Task #4”
Please note, this blog entry is from a previous course. You might want to check out the current one.
Add a ᐩ/- operation which changes the sign of the number in the display. Be careful with this one. If the user is in the middle of entering a number, you probably want to change the sign of that number and allow typing to continue, not force an enter like other operations do. On the other hand, if the user is not in the middle of typing a number, then this operation would work just like any other unary operation (e.g. cos).
Change the label of one of the “invisible” buttons to the +/- sign:
Continue reading “cs193p – Project #1 Assignment #1 Extra Task #3”
Please note, this blog entry is from a previous course. You might want to check out the current one.
When the user hits an operation button, put an = on the end of the UILabel you added in the Required Task above. Thus the user will be able to tell whether the number in the Calculator’s display is the result of a calculation or a number that the user has just entered. Don’t end up with multiple occurrences of = in your UILabel.
When the display value is set – which is basically every time an operation button is pressed – add the “=” to the history label but only if there is something to show:
var displayValue: Double { ... let stack = brain.showStack() if !stack!.isEmpty { history.text = stack! + " =" } ... }
Continue reading “cs193p – Project #1 Assignment #1 Extra Task #2”
Please note, this blog entry is from a previous course. You might want to check out the current one.
Implement a “backspace” button for the user to touch if they hit the wrong digit button. This is not intended to be “undo,” so if the user hits the wrong operation button, he or she is out of luck! It is up to you to decide how to handle the case where the user backspaces away the entire number they are in the middle of typing, but having the display go completely blank is probably not very user-friendly.
Change the label of one of the “invisible” buttons to “BS”:
Continue reading “cs193p – Project #1 Assignment #1 Extra Task #1”