iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman

iOS: Evil Hangman Walkthrough

Setup Getting Input Property Lists

CS164 Walkthrough Boy

Equivalence Classes Protocols Transitioning Between Views Settings

[email protected]

March 21, 2012

Today iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy

I

Evil Hangman

I

Setup

Setup

I

Getting Input

Getting Input

I

Property Lists

I

Equivalence Classes

I

Protocols

I

Transitioning Between Views

I

Settings

Evil Hangman

Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

Evil Hangman iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

it’s evil.

Evil Hangman iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup

I

goal: dodge user’s guess as best as possible

Getting Input

I

strategy: be able to switch among the most words

Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

maximize ability to cheat

Evil Hangman iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

- - -

I

words: OWN, PUN, LOL, NVM, NOT, WON, NEW

Evil Hangman iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman

I

- - -

Setup

I

words: OWN, PUN, LOL, NVM, NOT, WON, NEW

Getting Input

I

guess: N

Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I I I

- - -: LOL N - -: NVM, NOT, NEW - - N: OWN, PUN, WON

Evil Hangman iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup

I

- - N

I

words: OWN, WON, PUN

I

guess: P

Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I I

- - N: OWN, WON P - N: PUN

Evil Hangman iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman

I

- - N

Setup

I

words: OWN, WON, PUN

Getting Input

I

guess: O

Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I I I

- - N: PUN O - N: OWN - O N: WON

Evil Hangman iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman

I

W - N

Getting Input

I

words: WON

Property Lists

I

guess: O

Setup

Equivalence Classes Protocols Transitioning Between Views Settings

I

you win!

Evil Hangman iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

optimize at each step to find best solution

I

at each guess, leave yourself maximum number of words remaining

Setup iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman

I

Utility Application

Setup Getting Input

I

Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I I

contains two controllers: MainViewController and FlipsideViewController flipside often used for settings, etc. e.g., Weather app

Git iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input

I

built into XCode!

I

File > Source Control > Repositories... > Remotes > Add Remote

I

File > Source Control > Commit

Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

Setup iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

AnnotatedUtilityApp

Getting Input iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup

I

must come from a UITextField

Getting Input

I

UITextFieldDelegate provides greater access

I

probably don’t want to show the text field

Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

Getting Input iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

HiddenUITextFieldExample

plists iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

key/value pairs, frequently used to store settings

I

stored as XML, editable in raw form or using XCode’s plist editor

Syntax iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

array David Rob

Loading plist Files iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup

I

I

Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

NSDictionary can initWithContentsOfFile

I

can also writeToFile

NSBundle accesses filesystem via pathForResource:ofType:

Using plists iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

PropertyListExample

Equivalence Classes iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

Wikipedia says: [a] = {x ∈ X |x ∼ a}

I

clear? okay we’re done, have a nice night

Equivalence Classes iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

no, there’s no NSEquivalenceClass either

Equivalence Classes iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input

I

define a set of words sharing a given letter at a location

I

order matters!

Property Lists

I

Equivalence Classes

I

Protocols Transitioning Between Views Settings

- - N, N - - represent different equivalence classes don’t forget the set of words not containing the guessed letter

Equivalence Classes iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy

I

group words into equivalence classes based on user input

I

how do we define the collection of words in an equivalence class?

Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I I I

NSMutableDictionary NSMutableArray NSMutableSet

Equivalence Classes iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

for each word in set: determine equivalence class for word; add word to equivalence class; determine largest equivalence class; remove all words in complement of largest equivalence class; update UI;

Equivalence Classes iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input

I

each equivalence class contains a set of words

I

also need to keep track of all equivalence classes

Property Lists

I

Equivalence Classes

I

Protocols Transitioning Between Views Settings

make sure to pick the largest class ties must be broken psuedorandomly

Time Consumption iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

iterating through long lists is SLOW

I

indexing into arrays/dictionaries is FAST

Space Consumption iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman

I

words.plist is pretty big!

Getting Input

I

keep data structures as small as possible

Property Lists

I

don’t bother keeping things in memory that don’t need to be

Setup

Equivalence Classes Protocols Transitioning Between Views Settings

Design iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

“We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%.” – Donald Knuth

Protocol iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

list of methods that should be implemented @protocol SomeProtocol - (void)someMethod; @end

Protocol Usage iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup

I

why bother?

I

multiple classes can implement the same protocol

Getting Input

I

Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

different from extending a class, since protocol methods aren’t already defined

implementing protocol ensures object can respond to a given message

Protocol Usage iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup

I

Evil Hangman requires two strategies: Good and Evil

I

but, both strategies really do the same thing: respond to a move

I

if both implement the same protocol, we can pass the same message to either

Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

Protocols iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

CustomProtocolExample

UIViews iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

high scores should be displayed using a modal

I

requires a new HistoryViewController.{h,m,xib}

UIViews iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup

I

Getting Input

I

Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

HistoryViewController needs an alloc and initWithNibNamed

I

doesn’t know what xib to use, so needs to be passed

can then presentModalViewController

NSUserDefaults iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input

I

NSUserDefaults capable of storing persistent key/value pairs

Property Lists

I Equivalence Classes Protocols Transitioning Between Views Settings

without the hassle of implementing a database

NSUserDefaults iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy

I

[NSUserDefaults standardUserDefaults] gets defaults associated with the app

I

setObject:forKey: saves a key/value pair into defaults

I

objectForKey: retrieves a value

I

removeObjectForKey: removes an item

I

synchronize commits changes

Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

NSUserDefaults iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy

I

can read/write anything saveable in a plist

Evil Hangman

I

Setup Getting Input Property Lists Equivalence Classes

I

convenience methods I

Protocols Transitioning Between Views Settings

NSData, NSString, NSNumber, NSDate, NSArray, or NSDictionary

I

arrayForKey, dictionaryForKey, integerForKey, etc. setBool, setInteger, etc.

NSUserDefaults iOS: Evil Hangman Walkthrough CS164 Walkthrough Boy Evil Hangman Setup Getting Input Property Lists Equivalence Classes Protocols Transitioning Between Views Settings

I

NSUserDefaultsExample

iOS: Evil Hangman Walkthrough - cs164

Mar 21, 2012 - Property Lists. Equivalence. Classes. Protocols. Transitioning. Between. Views. Settings. iOS: Evil Hangman Walkthrough. CS164 Walkthrough ...

128KB Sizes 0 Downloads 321 Views

Recommend Documents

iOS: Evil Hangman Walkthrough - cs164
Mar 21, 2012 - for each word in set: determine equivalence class for word; add word to equivalence class; determine largest equivalence class; remove all ...

Evil Hangman - cs164
thereafter, you might also want to sign up for the iOS Developer Program at ... Because the course is part of the iOS Developer University Program, you will be ...

Evil Hangman - cs164
thereafter, you might also want to sign up for the iOS Developer Program at ... Because the course is part of the iOS Developer University Program, you will be ...

iOS: Evil Hangman Walkthrough - cdn.cs76.net
Apr 7, 2011 - Hangman. Walkthrough. Tommy. MacWilliam. Evil Hangman. Setup. Equivalence. Classes. Tips and. Tricks. iOS: Evil Hangman Walkthrough.

iOS: Evil Hangman Walkthrough - cdn.cs76.net
Apr 7, 2011 - goal: dodge user's guess as best as possible. ▷ strategy: be able to switch among the largest number of words. ▷ maximize ability to cheat.

Evil Hangman - CS50 CDN - cs164
should be prompted to Create an Apple ID or Use an existing Apple ID. Review the explanation beneath each option, select the appropriate one, click Continue, then follow the on-‐screen prompts. If you plan to submit an app to Apple's App Store, whe

iOS: XCode and Interface Builder - cs164
Mar 7, 2012 - +: class methods, sent to class, not object (e.g. alloc). Page 5. iOS: XCode and Interface. Builder. Tommy. MacWilliam. Objective-C. Review.

iOS: XCode and Interface Builder - cs164
Mar 7, 2012 - iOS: XCode and Interface. Builder. Tommy. MacWilliam. Objective-C. Review. XCode. Interface. Builder. Outlets and. Actions. Delegates and.

Seal Of Evil 1.06 Walkthrough Chapter 123.pdf
There was a problem previewing this document. Retrying... Download. Connect more apps... Try one of the apps below to open or edit this item. Seal Of Evil 1.06 ...

Untitled - cs164
High Performance MySQL. Page 12. partitioning. High Performance MySQL. Page 13. high availability. High Performance MySQL. Page 14. realtime apps ...

Specification - cs164
need a Mac for the course until Mon 3/19, but Xcode comes with iOS Simulator, which might prove handy for testing in the short term. If you do have a Mac, know ...

Specification - cs164
Computer Science 164: Mobile Software Engineering. Harvard College .... Log into your Bitbucket account and create a new, private repo as follows: □ Select ...

Syllabus - cs164
Computer Science 164: Mobile Software Engineering ... Description .... intend to use outside of the course (e.g., for a job) must be approved by the staff. ... Administrative Board and the outcome for some student is Admonish, Probation, ...

Mobile Software Engineering - cs164
singletons, factories, observers, ... Page 23. unit testing. PHPUnit, Selenium, ... Page 24. UX. Page 25. performance latency, caching, ... Page 26. source control git, subversion. Page 27. IDEs. Xcode, ... Page 28. PHP frameworks. CodeIgniter. Page

Specification - cs164
Fri. 2/3. Proposal. 2/6. Design Doc, Style Guide. 2/10. Beta. 2/24. Release ... or otherwise exposed) or lifting material from a book, website, or other ... Help is available throughout the week at http://help.cs164.net/, and we'll do our best to res

Untitled - cs164
web hosts. Bluehost. DreamHost. Go Daddy. Host Gator pair Networks ... Page 3. VPSes. DreamHost. Go Daddy. Host Gator. Linode pair Networks. Slicehost.

Walkthrough 8
index.html – homepage. ▫ buildings.js – buildings in the game. ▫ houses.js – Harvard houses + locations. ▫ math3d.js – movement math. ▫ passengers.js – all the people in the game. ▫ service.css – appearance of the homepage. ▫

design patterns - cs164
sections labs design reviews, code reviews, office hours alphas new release cycle. Page 5. new release cycle. Page 6. workload. Page 7. project 1. Page 8 ...

Walkthrough 8
Agenda. ▫ Distribution Code. ▫ HTML + CSS. ▫ Javascript. ▫ API's: Google Earth and Google Maps. ▫ Pickup. ▫ Dropoff. ▫ Choice of feature ...

Walkthrough 8
index.html – homepage. ▫ buildings.js – buildings in the game. ▫ houses.js – Harvard houses + locations. ▫ math3d.js – movement math. ▫ passengers.js – all the ...

CS 50 Walkthrough 5
Data structures, hexadecimal, and pointers. • Programs: – whodunit. – resize. – recover ... Image recovery! ... Go through each block in the disk image and: 1.

CS 50 Walkthrough 5
Image recovery - Steps. • Steps: Go through each block in the disk image and: 1. If we find a JPEG signature, start wriûng the bytes out to another file. 2. If we find a new JPEG signature, close that old file and go back to 2. 3. If we find the E

CS50 Walkthrough 4
To Do. ▫ distribution code. ▫ ncurses. ▫ move cursor. ▫ allow changing user-added ... Allows you to change colors, ... g.board[g.y][g.x] is spot on board where.