Following along with the Stanford CS193p iOS course is great because one of the projects is basically a twitter feed so I can look at pictures of dogs all day but pretend I’m testing my app


#dc comics#batman#dc#bruce wayne#tim drake#dick grayson#dc universe#batfamily#batfam#dc fanart



seen from Malaysia
seen from Uruguay

seen from United States
seen from United States
seen from Türkiye

seen from United States

seen from United States
seen from United States
seen from Iraq

seen from Canada
seen from Canada

seen from United States
seen from China
seen from United States
seen from India

seen from Canada
seen from United States
seen from United States
seen from United States
seen from United States
Following along with the Stanford CS193p iOS course is great because one of the projects is basically a twitter feed so I can look at pictures of dogs all day but pretend I’m testing my app
Time flies … so much to do … so little time … … and a new course overtook my work on this page. Let’s do a reset, I will start with the new cs193p of Winter 2017. … and if you would like to speed up the process, don’t hesitate and click on the tiny … Continue reading "cs193p – RESET"
The Animation assignment also referred to as the Breakout game is the 5th and final assignment from the CS193P course Developing iOS 8 Apps with Swift from Stanford University. Really happy to have finally finished this assignment. In my opinion this was the most complex of all the five assignments in this course.
Platform: iOS 9 Swift: 2.1
Full source code available here at the Github repository
#gallery-0-6 { margin: auto; } #gallery-0-6 .gallery-item { float: left; margin-top: 10px; text-align: center; width: 33%; } #gallery-0-6 img { border: 2px solid #cfcfcf; } #gallery-0-6 .gallery-caption { margin-left: 0; } /* see gallery_shortcode() in wp-includes/media.php */
All the 9 required tasks mentioned in page 2 of the specifications document were completed. Though device rotation is not mentioned as a requirement it does appear as a hint. I didn’t allow device rotation because it seemed to me that it would drastically affect the game play negatively.
The main challenge that I faced in completing this assignment was the nuance of using UIKit Dynamics to make a game. There were numerous issues that I was not fully clear in the beginning on how to implement them. So slowly chipped away each issue one by one before I had a clear picture of how they all fit together.
I am summarizing some of the main issues I had problems with below and how I solved them. Please see the inline documentation in the source code for all the issues and their implementation details.
Creating the ball and animating it: The shape of the rectangular view of the ball as the collision boundary didn’t seem right. Though prior to iOS 9 I don’t think it was possible to do anything about it. Please see Variation on Dropit Demo from Lecture 12 on how I solved this by setting UIDynamicItemCollisionBoundsType to be an .Ellipse.
Animating the paddle on pan gesture and having the ball collide. Hints are given in the assignment specifications on how to implement this, but since I hadn’t done it before it wasn’t clear what the outcome would look like. The solution is to add the paddle as a subview of the game view and additionally create a bezier path that acts as a collision boundary in the UIDynamicBehavior subclass. Then update that boundary repeatedly whenever the paddle moves. Please see the movePaddle and syncPaddleBoundary methods for details.
When the paddle was moved too quickly when hitting a ball, the ball would often end up trapped inside the paddle. The way I solved this is first check if the new paddle view’s frame intersected with the balls frame using CGRectIntersectsRect. If the frames don’t intersect then update / sync the boundary.
Bricks are setup similar to the paddle, where they are added to the game view and their colliding boundaries added to the UIDynamicBehavior subclass. The ball collides with the boundary and when a collision is detected, the brick is removed from the game view. A bricks array [String:Brick] is used to track all the bricks in the game view and match them against the NSCopying identifier from the collision delegate. For details please see the methods createBricks and collisionBehavior.
Special bricks and what behavior they would cause were open ended in the assignment specifications. I used 4 kinds of special bricks, one kind requires 3 hits before it disappears and the other three drops special powers that cause:
paddles to become larger
paddles to become smaller
adds additional balls
Pausing the game when user taps on Settings. This wasn’t too hard to implement, the main issue here is the moving ball(s). I used an array to capture the balls and remove them from the screen. When user came back, I re-created them and added back their linear velocity. Please see method settingsDidUpdate.
Instead of putting up an alert when the game ends, a view is used (where it’s state is toggled) to show that the game is over indicating if you won or lost. This view is also used during startup. The startGame and gameOver methods show how this is done.
The following extra credit tasks were also attempted:
Use sophisticated Dynamic Animation. For example, you might find a creative way to use the action method in a behavior or use something like linear velocity in your calculations.
As mentioned above, creativity will be rewarded, especially interesting game-play settings.
Do some cool artistic design in your user-interface (either by drawing or using images).
Pausing your game when you navigate away from it (to go to settings) is a bit of a challenge (because you basically have to freeze the ball where it is, but when you come back, you have to get the ball going with the same linear velocity it had). Give it a try. It’s all about controlling the linear velocity of the ball.
Animation / Breakout: Assignment 5, CS193P, Stanford University (Winter 2015) The Animation assignment also referred to as the Breakout game is the 5th and final assignment from the CS193P course Developing iOS 8 Apps with Swift from Stanford University.
GraphingCalculator: Assignment 3, Stanford University, CS193P, Winter 2015
GraphingCalculator: Assignment 3, Stanford University, CS193P, Winter 2015
The Graphing Calculator project is a continuation of the previous 2 assignments from the Stanford University CS193P course Developing iOS 8 Apps with Swift, available for free on iTunes. This is the third and final assignment in the Calculator series. Full source code available here at Github repository For the other 2 projects, please see: CalculatorBrain: Assignment 2, Stanford University…
View On WordPress
Swift Optionals
Optionals are enums. With case None, and case Some(T). <T> is just a generic.
let x: String? = nil
is the same as
let x = Optional<String>.None
let x: String? = “hello”
is the same as
let x = Optional<String>.Some(”hello”)
exclamation mark and question marks are syntactic sugar.
Optionals can be “Chained”:
if let x = display?.text?.hashValue {...}
chain the optionals. So if any of these are uninitialized, then the whole thing is just nil.
There is also a default operator for optionals.
display.text = s ?? “ ”
CS193p Reading Assignment 1
The Basics
1.) Constants and Variables
Associate a name with a value of a particular type. For instance, maximumNumberOfLoginAttempts or welcomeMessage could hold the values 10 and “Hello!”.
The major difference between constants and variables is that variables may hold values that change over time, whereas constants, once set, must remain...well...constant.
Declaration:
let maximumNumberOfLoginAttempts = 10
var currentLoginAttempt = 0
Declaration of multiple variables or constants can be made on a single line like this:
var x = 0.0, y = 0.0, z = 0.0
Type Annotations help make it clear what kind of values a particular variable or constant can store. To provide a type annotation, separate the name of the variable or constant and its type by a colon, like this:
var welcomeMessage: String
can then be set
welcomeMessage = “Hello”
Type Annotations are typically rare as Swift is a strongly typed language and supports type inference, which is a fancy way of saying that the language understands what type a variable or constant is supposed to be as soon as it is set. Type Annotations help when initialization does not happen right off the bat, like the above example.
Constants and variables can hold almost any character, including Unicode. The following examples are all valid:
let ∞ = "forever”
let 1️⃣2️⃣3️⃣ = 123
Sometimes it’s helpful to print the values of various variables or constants throughout the development process. In Swift, printing those values to the debug area of Xcode is easy using the println() global function. println() prints a value followed by a line break to the console pane (debug area) at the bottom of the main Xcode window.
The println() function can print more complex logging message that include the current values of constants and variables. To do so, we use what is known in the Swift language as string interpolation. Interpolated strings act as placeholders within longer strings that will display dynamic values. To interpolate a string in Swift, wrap the name in parentheses and escape it with a backslash, like this:
var favoriteFood = “BBQ”
println(”My favorite food is \(favoriteFood).”)
this would print
My favorite food is BBQ.
2.) Comments
When the need to include non-executable text within your code arises, comments can be an extremely useful tool. Comments are left out when code is compiled and can be included in one of two ways. Comments are great ways to include things like notes or reminders to yourself.
Single-line comments begin with two forward-slashes, like this:
// this is a comment
Multiline comments are wrapped by forward-slash / asterisk combinations, like this:
/* this is also a comment,
but it is written over multiple
lines */
Comments in Swift differ from comments in C in that multiline comments can be nested within other multiline comments, like so:
/* this is the start of the first multiline comment
/* this is the second, nested multiline comment */
this is the end of the first multiline comment */
3.) Semicolons
Swift differs from many other languages in that semicolons are not required after each statement in your code. Although the compiler won’t mind if you do, it’s absolutely unnecessary for you include them. The only time semicolons become necessary is when you want to write multiple separate statements on a single line, like this:
let baaaah = “🐑”; println(baaaah)
4.) Integers
Whole numbers with no fractional components such as 8 or 15 or -150 are known as integers. Integers can either be signed (positive, zero, or negative) or unsigned (positive or zero).
Types of signed and unsigned integers provided by Swift and their respective type names:
8 bit (UInt8, Int8)
16 bit (UInt6, Int16)
32 bit (UInt32, Int32)
64 bit (UInt64, Int64)
Accessing the minimum and maximum values of each integer type is easy, just access the min and max class properties using dot notation, like this:
let minimumValue = UInt8.min
minimumValue is equal to 0
let maximumValue = UInt8.max
maximumValue is equal to 255
Usually you don’t need to be concerned with the specific size on an integer in your code. That’s why Swift provides an additional type, Int, which has the same size as the current platform’s native word size. So, on a 32-bit platform, Int is the same size as Int32. On a 64-bit platform, Int is the same size as Int64. Expectedly, Swift also offers an unsigned versions of Int as well - UInt. On a 32-bit platform, Uint is the same size as UInt32. On a 64-bit platform, Uint is the same size as UInt64.
It’s not common to specify an Int as unsigned (U) and Int is typically preferred, even when the values to be stored are known to be non-negative. This practice promotes code interoperability and keeps you as a programmer from having to convert between different number types. It’s also more closely aligned with Swift’s strong type inference system for integers.
5.) Floating-Point Numbers
Whereas integers represent whole values, floating-point numbers represent values with fractional components. For instance, 3.14159, 0.1, and -273.15 are all examples of floating-point numbers. These kinds of numbers can represent much larger ranges of values than integers. In Swift, you’re provided two types of floating-point numbers:
Double
64-bit floating point number. Typically used in cases where floating-point values need to be very, very large or incredibly precise.
Offers precision level of at least 15 decimal digits.
Float
32-bit floating point number. Use when floating-point values don’t necessarily need to include 64-bit precision.
Offers precision of at least 6 decimal digits.
6.) Type Safety and Type Inference
Due to Swift’s construction as an extremely type-safe language, you’ll need to be extra careful when assigning values to parts of your code. You won’t be completely on your own, though. As you’re working, the compiler will pick up any type mismatches and warn you about them so you can catch your mistakes early on. For instance, if you try to assign a String to a variable that’s already been typed as an Int, you’ll get an error message and get a chance to correct your mistake before your whole program crashes. As mentioned above in the section surrounding Type Annotations, you won’t actually need to specify what type of value a variable should be expecting if you provide a value at the time of initialization. These values, which appear directly in your source code, are known as literal values. For example, assigning the value 7 to a new constant called myFavoriteNumber will let the compiler know behind the scenes that the new constant is of type Int. This is known as type inference.
In the case of floating-point numbers, Swift always chooses Double (rather than Float) during type inference. For example, in the statement let pi = 3.14159, pi is inferred to be of type Double. If you were to combine an integer with a floating-point literal, Swift will automatically combine them into an inferred Double. For example, let anotherPi = 3 + 0.14159 will be inferred to be of type Double.
Stanford University CS193p Fall (2011-12) lecture index
iOS overview
Cocoa Touch
Media
Core Services
Core OS
MVC
M:What your application is.
Notification & KVO(Key Value Object)
V:Your Controller’s minions
notify actions to controller
delegate to controller
give data source to controller
C:How your Model is presented to the user(UI logic).
give outlets to view and model
have target
should/will/did
data at/count
Objective-C grammer
.h
#import <foo/bar.h> or “hoge.h” @interface ClassName : SuperClassName @property (nonatmic|weak|strong) Type propertyName; - (ReturnType)argumentName1:(argumentType1 *)name1 argumentNameN:(argumentTypeN *)nameN; @end
.m
#import OwnHeader.h @interface ClassName() @property (nonatmic|weak|stromg) Type *privatePropertyName; @end @implementation ClassName @synthesize propertyName = _propertyName; @synthesize privatePropertyName = _privatePropertyName - (void) setPropertyName:(argumentType *)propertyName { // You could write any special code to set property if you need. // Else, delete it. } - (ReturnType)propertyName { // You could write any special code to get property if you need. // Else, delete it. } - (ReturnType)argumentName1:(argumentType1 *)name1 argumentNameN:(argumentTypeN *)nameN { type variable = [object message]; type variable = object.propertyName; // same as above. [[object message] argumentName1:argument 1 argumentNameN:argumentN]; } @end
from Stanford University CS 193P iPhone Application Development Fall (2011-12)
*This work by Stanford University is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. Based on a work at cs193p.stanford.edu
CS193p 関連サイト(日本)
参考のためにめメモ。日本でも英語にめげずにやってて頭が下がる。そして周回遅れなんじゃないかとか思ったりもする。
Takayuki Ogino Macのことなど Macで遊んでる
宮城大学 こじ研(携帯メディア)(2009-10 Winter) iPhone アプリ開発道場
ニコニコ動画(2009-10 Winter) ニコニコ動画
AKISUTE(2008-09 Winter) iPhone開発をこれから始めるときに参考にする資料
Seiji Toyama Custom Classの作成-CS193P
shiro(2009 Spring?) 同時進行でみるスタンフォード iPhone プログラミング:第1回開講