Skip to content

Commit

Permalink
Add ReadToMe and UIKitDynamics sample projects to repository.
Browse files Browse the repository at this point in the history
  • Loading branch information
tabinks committed Apr 7, 2015
1 parent 5c5ee0c commit b12a0b3
Show file tree
Hide file tree
Showing 39 changed files with 2,396 additions and 41 deletions.
4 changes: 2 additions & 2 deletions Session2-AttributedStrings.playground/contents.swift
Expand Up @@ -21,7 +21,7 @@ helloLabel.text = "Hello Label!"

//: Let the label use an attributed string instead
var attributedString = NSMutableAttributedString()
attributedString = NSMutableAttributedString(string: "Hello World!", attributes: [NSFontAttributeName:UIFont(name: "Georgia", size: 50.0)!])
attributedString = NSMutableAttributedString(string: "Hello World this is a demo!", attributes: [NSFontAttributeName:UIFont(name: "Georgia", size: 100.0)!])
helloLabel.attributedText = attributedString


Expand All @@ -33,7 +33,7 @@ Note that attributed string attributes are cumulative. They will persist on tha
*/

//: Changing the font attribute
attributedString = NSMutableAttributedString(string: "Hello World!", attributes: [NSFontAttributeName:UIFont(name: "ChalkboardSE-Regular", size: 50.0)!])
attributedString = NSMutableAttributedString(string: "Hello World!", attributes: [NSFontAttributeName:UIFont(name: "ChalkboardSE-Regular", size: 100.0)!])

//: Changing the font over a range
attributedString.addAttribute(NSFontAttributeName, value: UIFont(name: "AmericanTypewriter-Bold", size: 18.0)!, range: NSRange(location:0,length:5))
Expand Down
43 changes: 24 additions & 19 deletions Session2-AttributedStrings.playground/timeline.xctimeline
Expand Up @@ -3,98 +3,103 @@
version = "3.0">
<TimelineItems>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=879&amp;EndingColumnNumber=11&amp;EndingLineNumber=23&amp;StartingColumnNumber=1&amp;StartingLineNumber=23&amp;Timestamp=450023122.693049"
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=896&amp;EndingColumnNumber=11&amp;EndingLineNumber=23&amp;StartingColumnNumber=1&amp;StartingLineNumber=23&amp;Timestamp=450054829.455553"
lockedSize = "{425, 138}"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=1357&amp;EndingColumnNumber=11&amp;EndingLineNumber=36&amp;StartingColumnNumber=1&amp;StartingLineNumber=36&amp;Timestamp=450023680.926571"
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=1374&amp;EndingColumnNumber=11&amp;EndingLineNumber=36&amp;StartingColumnNumber=1&amp;StartingLineNumber=36&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=7&amp;CharacterRangeLoc=1403&amp;EndingColumnNumber=16&amp;EndingLineNumber=39&amp;StartingColumnNumber=1&amp;StartingLineNumber=39&amp;Timestamp=450023680.926721"
documentLocation = "#CharacterRangeLen=7&amp;CharacterRangeLoc=1420&amp;EndingColumnNumber=16&amp;EndingLineNumber=39&amp;StartingColumnNumber=1&amp;StartingLineNumber=39&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=2007&amp;EndingColumnNumber=16&amp;EndingLineNumber=46&amp;StartingColumnNumber=1&amp;StartingLineNumber=46&amp;Timestamp=450023680.926865"
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=2024&amp;EndingColumnNumber=16&amp;EndingLineNumber=46&amp;StartingColumnNumber=1&amp;StartingLineNumber=46&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=879&amp;EndingColumnNumber=11&amp;EndingLineNumber=26&amp;StartingColumnNumber=1&amp;StartingLineNumber=26&amp;Timestamp=450023122.693049"
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=896&amp;EndingColumnNumber=11&amp;EndingLineNumber=26&amp;StartingColumnNumber=1&amp;StartingLineNumber=26&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=2161&amp;EndingColumnNumber=16&amp;EndingLineNumber=46&amp;StartingColumnNumber=1&amp;StartingLineNumber=46&amp;Timestamp=450023680.927138"
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=2178&amp;EndingColumnNumber=16&amp;EndingLineNumber=46&amp;StartingColumnNumber=1&amp;StartingLineNumber=46&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=10&amp;CharacterRangeLoc=834&amp;EndingColumnNumber=11&amp;EndingLineNumber=24&amp;StartingColumnNumber=1&amp;StartingLineNumber=24&amp;Timestamp=450023122.693049"
documentLocation = "#CharacterRangeLen=10&amp;CharacterRangeLoc=851&amp;EndingColumnNumber=11&amp;EndingLineNumber=24&amp;StartingColumnNumber=1&amp;StartingLineNumber=24&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=10&amp;CharacterRangeLoc=556&amp;EndingColumnNumber=11&amp;EndingLineNumber=18&amp;StartingColumnNumber=1&amp;StartingLineNumber=18&amp;Timestamp=450023122.693049"
documentLocation = "#CharacterRangeLen=10&amp;CharacterRangeLoc=572&amp;EndingColumnNumber=11&amp;EndingLineNumber=18&amp;StartingColumnNumber=1&amp;StartingLineNumber=18&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=134&amp;CharacterRangeLoc=1223&amp;EndingColumnNumber=141&amp;EndingLineNumber=35&amp;StartingColumnNumber=20&amp;StartingLineNumber=35&amp;Timestamp=450023680.927549"
documentLocation = "#CharacterRangeLen=134&amp;CharacterRangeLoc=1240&amp;EndingColumnNumber=141&amp;EndingLineNumber=35&amp;StartingColumnNumber=20&amp;StartingLineNumber=35&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=16&amp;CharacterRangeLoc=1394&amp;EndingColumnNumber=17&amp;EndingLineNumber=38&amp;StartingColumnNumber=1&amp;StartingLineNumber=38&amp;Timestamp=450023680.927689"
documentLocation = "#CharacterRangeLen=16&amp;CharacterRangeLoc=1411&amp;EndingColumnNumber=17&amp;EndingLineNumber=38&amp;StartingColumnNumber=1&amp;StartingLineNumber=38&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=2161&amp;EndingColumnNumber=17&amp;EndingLineNumber=46&amp;StartingColumnNumber=1&amp;StartingLineNumber=46&amp;Timestamp=450023680.927841"
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=2178&amp;EndingColumnNumber=17&amp;EndingLineNumber=46&amp;StartingColumnNumber=1&amp;StartingLineNumber=46&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=2007&amp;EndingColumnNumber=17&amp;EndingLineNumber=45&amp;StartingColumnNumber=1&amp;StartingLineNumber=44&amp;Timestamp=450023680.927967"
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=2024&amp;EndingColumnNumber=17&amp;EndingLineNumber=45&amp;StartingColumnNumber=1&amp;StartingLineNumber=44&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=16&amp;CharacterRangeLoc=2009&amp;EndingColumnNumber=17&amp;EndingLineNumber=46&amp;StartingColumnNumber=1&amp;StartingLineNumber=46&amp;Timestamp=450023680.928092"
documentLocation = "#CharacterRangeLen=16&amp;CharacterRangeLoc=2026&amp;EndingColumnNumber=17&amp;EndingLineNumber=46&amp;StartingColumnNumber=1&amp;StartingLineNumber=46&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=16&amp;CharacterRangeLoc=1868&amp;EndingColumnNumber=17&amp;EndingLineNumber=43&amp;StartingColumnNumber=1&amp;StartingLineNumber=43&amp;Timestamp=450023680.928217"
documentLocation = "#CharacterRangeLen=16&amp;CharacterRangeLoc=1885&amp;EndingColumnNumber=17&amp;EndingLineNumber=43&amp;StartingColumnNumber=1&amp;StartingLineNumber=43&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=16&amp;CharacterRangeLoc=682&amp;EndingColumnNumber=17&amp;EndingLineNumber=19&amp;StartingColumnNumber=1&amp;StartingLineNumber=19&amp;Timestamp=450024246.183628"
documentLocation = "#CharacterRangeLen=16&amp;CharacterRangeLoc=1112&amp;EndingColumnNumber=17&amp;EndingLineNumber=23&amp;StartingColumnNumber=1&amp;StartingLineNumber=23&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=134&amp;CharacterRangeLoc=546&amp;EndingColumnNumber=154&amp;EndingLineNumber=17&amp;StartingColumnNumber=20&amp;StartingLineNumber=17&amp;Timestamp=450024246.183628"
documentLocation = "#CharacterRangeLen=10&amp;CharacterRangeLoc=252&amp;EndingColumnNumber=11&amp;EndingLineNumber=8&amp;StartingColumnNumber=1&amp;StartingLineNumber=8&amp;Timestamp=450024246.183628"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=16&amp;CharacterRangeLoc=1095&amp;EndingColumnNumber=17&amp;EndingLineNumber=23&amp;StartingColumnNumber=1&amp;StartingLineNumber=23&amp;Timestamp=450024246.183628"
documentLocation = "#CharacterRangeLen=10&amp;CharacterRangeLoc=495&amp;EndingColumnNumber=11&amp;EndingLineNumber=13&amp;StartingColumnNumber=1&amp;StartingLineNumber=13&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=10&amp;CharacterRangeLoc=252&amp;EndingColumnNumber=11&amp;EndingLineNumber=8&amp;StartingColumnNumber=1&amp;StartingLineNumber=8&amp;Timestamp=450024246.183628"
documentLocation = "#CharacterRangeLen=16&amp;CharacterRangeLoc=699&amp;EndingColumnNumber=17&amp;EndingLineNumber=19&amp;StartingColumnNumber=1&amp;StartingLineNumber=19&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=135&amp;CharacterRangeLoc=562&amp;EndingColumnNumber=155&amp;EndingLineNumber=17&amp;StartingColumnNumber=20&amp;StartingLineNumber=17&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
<LoggerValueHistoryTimelineItem
documentLocation = "#CharacterRangeLen=10&amp;CharacterRangeLoc=479&amp;EndingColumnNumber=11&amp;EndingLineNumber=13&amp;StartingColumnNumber=1&amp;StartingLineNumber=13&amp;Timestamp=450024246.183628"
documentLocation = "#CharacterRangeLen=16&amp;CharacterRangeLoc=1221&amp;EndingColumnNumber=17&amp;EndingLineNumber=25&amp;StartingColumnNumber=1&amp;StartingLineNumber=25&amp;Timestamp=450054829.455553"
selectedRepresentationIndex = "0"
shouldTrackSuperviewWidth = "NO">
</LoggerValueHistoryTimelineItem>
Expand Down
43 changes: 23 additions & 20 deletions Session2-ClassesAndObjects.playground/contents.swift
Expand Up @@ -48,22 +48,7 @@ Stored and Computed Properties
*/
class Box {
var numberOfSides = 4 // Stored property
var description: String { // Computed property
get { return "\(numberOfSides) wheels" }
// You can create an optional setter (if it makes sense)
// set {
// }

// You can omit the get {} if only using a getter
}

// Lazy Properties
var firstVisit: Bool = false
lazy var bigImage: UIImage = UIImage(named: "ReallyBigImage")!
func login() {
if (firstVisit == false) {
//self.imageView.image = bigImage
}
var description: String { // Computed property return "\(numberOfSides) wheels"
}
}

Expand Down Expand Up @@ -97,18 +82,30 @@ Initializers

class NamedShape {
var numberOfSides: Int = 0
var name: String
var name: String!
var noname: String?


init(name: String) {
// Need to use `self` if property has same name as parameter
self.name = name
//self.name = name
self.name = "forced"
self.noname = "optional"
}

func simpleDescription() -> String {
return "A shape with \(numberOfSides) sides."
}
}

var a = NamedShape.init(name:"hi")
println(a.name)
println(a.noname!)

if let n = a.noname {
println(n)
}

/*:
> A couple of things to note:
> - Unlike Obj-C, initializers do not return a value.
Expand Down Expand Up @@ -163,10 +160,12 @@ class Animal {

class Dog: Animal {
var hasFourLegs: Bool

init(animalName: String, fourLegs: Bool) {
// Initialize all subclass properteis before calling superclass
hasFourLegs = fourLegs
super.init(animalName: animalName)
name = "RUFF"
}

// Convienence initializer
Expand Down Expand Up @@ -261,8 +260,12 @@ counter.incrementBy(2, numberOfTimes: 7)
//: ### Optional Class Instances
//: - When working with optional values, you can write ? before operations like methods, properties, and subscripting.
//: - If the value before the ? is nil, everything after the ? is ignored and the value of the whole expression is nil. This is called **optional binding**. Otherwise, the optional value is unwrapped, and everything after the ? acts on the unwrapped value. In both cases, the value of the whole expression is an optional value.
let optionalSquare: Square? = Square(sideLength: 2.5, name: "optional square")
let sideLength = optionalSquare?.sideLength
var optionalSquare: Square? //= Square(sideLength: 4.5, name: "optional square")

// ????
var s = optionalSquare?.sideLength
println(s)




Expand Down
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>mobi.uchicago.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
@@ -0,0 +1,17 @@
//
// Prefix header
//
// The contents of this file are implicitly included at the beginning of every source file.
//

#import <Availability.h>

#ifndef __IPHONE_5_0
#warning "This project uses features only available in iOS SDK 5.0 and later."
#endif

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#endif
15 changes: 15 additions & 0 deletions Session2-ReadToMe/2014-Spring-ReadToMe/AppDelegate.h
@@ -0,0 +1,15 @@
//
// AppDelegate.h
// 2014-Spring-ReadToMe
//
// Created by T. Andrew Binkowski on 4/4/14.
// Copyright (c) 2014 The University of Chicago, Department of Computer Science. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
46 changes: 46 additions & 0 deletions Session2-ReadToMe/2014-Spring-ReadToMe/AppDelegate.m
@@ -0,0 +1,46 @@
//
// AppDelegate.m
// 2014-Spring-ReadToMe
//
// Created by T. Andrew Binkowski on 4/4/14.
// Copyright (c) 2014 The University of Chicago, Department of Computer Science. All rights reserved.
//

#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end

0 comments on commit b12a0b3

Please sign in to comment.