iPhone 7 Review

Written by on

= [ music ] >> stanford university. >> okay, well welcometo lecture number 3 of cs193p for fall of 2013/14. today i'm going to jumpright into a demo and then after that i have someslides, time permitting, assuming the demo doesn't take[pause] the whole time here, and after, the demo i'mgoing to do is i'm going

to take the little card thingwe did last week and turn it into a real card matching game where we're actuallymatching cards, okay, rather than justflipping them over. and, like i say, if i have thetime i'll talk a little bit more about objective-c andwe're really going to go into objective-c on wednesdayin quite a bit of detail. i also included on the stuffi posted some review slides at the end just kind

of reviewing whatwe will have learned in the first three lectures,just so you can kind of look through it real quick andsay oh yeah, do i know that? yeah i do, and if not,than you can obviously post and ask us questions about it. okay? so, let's do this demo. so for the demo [backgroundsounds], i'm going to startthis demo actually by giving you thesolution to the homework,

i told you i was going to dothis, this is the only time that i'm going to dothis this quarter. normally i don't go over thesolution, but the solution's so simple and because obviouslywe need the solution of this to move on to whati'm going to do today. we'll do the solution first. so here i'm just launchingxcode, you can see now in my recents i have thismachismo from last time. so, we'll bring that up.

there it is. make sure that we're using as much screen realestate as we can here. get these wires out of my way. okay. so, from where we leftoff, hopefully you remember because you did your homework. we just have this single,this card, single card, and it flips back and forthbetween the ace and the clubs, and your homework was touse the model that we worked

on in lecture to make itflip through an entire deck. so, the solution to thatis quite straightforward. we obviously need adeck so i'm just going to add a property here, strongproperty, should be strong because we need that deck to,to stay around, and it's going to be a deck and i'mgoing to call it deck. okay? now we have an errorhere because of deck, so we have to go uphere and import deck. alright? to makethat error go away.

so now we got this propertythat's cool, obviously we want to lose lazy instantiationto instantiate that property, so i'm going to do that,that's a deck [inaudible] deck, and i'm just going to see ifmy instance variable is null or nil, rather, the0, basically. then i'm going to say, sorry,underbar, underbar deck, equals, and i'm actually going to createdeck using another method here, you'll see why in asecond and then i'm going to return underbar deck.

okay? and create deck isjust going to create a deck. create deck and i'm going tocreate a playing card deck, because that's what you wereasked to do so i'm just going to do [inaudible] to do that. i got an error because notonly do i need to import deck, but playing card deck,and it's actually kind of unfortunate here that inthis nice, generic card game that i'm building, that i'mimporting a playing card deck. why is that unfortunate?

well, i'm going to tryand build a card game here that has nothing todo with playing cards. okay? it's goingto be a generic, should work with any kind ofdeck, okay, a deck of any kind of cards and, in fact, inyour homework, you're going to be asked to enhancedthe game next week to play a different deck. okay? so it's unfortunate that ihave to do this and in lecture, either on wednesday orprobably on monday, we will talk

about how we canget rid of this. okay, get this importplaying card deck and this create deck methodto be more generic, okay, not be so specificto playing cards. but anyway, so nowi have this deck and it's lazily instantiatedso now that i have a deck, i can use it to getrid of this little ace of clubs thing right here, okay? and, i'm going to do that bysaying here card star card

equals self dot deck,draw random card. so i'm going to draw arandom card out of the deck and then instead ofputting ace of clubs here, i'm going to putthe cards contents. okay? and that's really yourentire homework assignment, there's one other minor thingthat i'm going to do here, actually two minor things. because we don't want justa solution that works, this will work if we run this.

we're going to see it work, butit's kind of not very elegant and not really, it's not reallya really very good solution to the problem, even thoughit functions, you see, it's, it's going throughthe random cards here. but it was kind ofannoying, a couple of things. one, it started out with theace of clubs, that was kind of gross, okay, becauseif i keep clicking here, eventually i'm going toget the ace of clubs, there it was back again,so that's kind of bad.

the other thing is when thisdeck is empty, this is not going to particularly elegantly,you know, finish off, and we want to have someelegant solution and i said in the hints come upwith an elegant solution. also, this flips thing here, once i flip throughthe whole deck, it's going to keep flipping. you know, it's going tobe 102, 103, 104, 105, that's not very elegant either.

so let's fix all three ofthose things with simple, elegant solutions, okay? so my simple, elegantsolution to the ace of clubs which i hinted at for you issimply to start it face down. so i'm going to get the cardback here, get rid of the ace of clubs, and now thiscard starts out facedown. so i didn't have to write anycode and i just use my brain over my brawn to make surethat this works, right? so, that's kind of theelegant way of thinking

about solving that problem. so we'll just start itface down, there's no, there was no required taskthat said you had to start with the ace of clubs faceup, so that's a good solution. when it comes torunning out of cards, i think an elegant solutionis it just will stop flipping at that point. i mean, you could makearguments, load up another deck, other stuff, but i think asimple solution is just once you

run out of cards, you keepclicking, and it stops flipping. okay? so how are wegoing to do that? well, i know some of you aregoing to say something like, if number of flips equals102, then stop flipping, and that's really, really bad. that's a very bad design,because that 102 is like a magic number youjust put into your program and there's completely no reasonfor that bad design either. all you need to do is just sayif card, then flip it, okay,

so i'm going to flip it here, i'll make some morespace so you can see. otherwise, i'm notgoing to flip it. okay? so i'm just, this isa super elegant solution to, you know, not continuingto flip this thing over when the deck runs out, and we know that draw arandom card returns nil, if you remember from ourimplementation it returns nil when the deck isempty, so, perfect!

once it's nil, it's justnot going to flip back over to the contents sides, it's going to alwaysstay on the backside. question? [inaudiblebackground question] and flip count is thethird thing that was kind of not very elegant,so how can we fix that? well, you know, there's anumber of ways to go at that, but i think a simple wayis to only flip, sorry, when we actually dothe flipping over.

now, this is kind ofnot a great solution because here we're not actuallyflipping over, you know, if, if we're on the card back,then we're flipping over here, so this one's kind of not sogood, because we kind of gonna, once we flip over tothe back, we'll be okay because when we startto do [pause], we'll be executing this codeover and over right here because we'll alwaysbe on the back. so i think this'll work, right?

is that a good solution? the reason i don't like it isi don't like having this line of code in two differentplaces, kind of eh. i could have done a lotof other things here, we could have factored outthe image and the string into separate localvariables and had our if, apply those, andstuff like that. i think all of that would havebeen a little bit of overkill. so, let's see if this works.

so here's our thing here,so it started facedown. let's click throughthe deck here, i'll click through it quickly. so i'm clicking so quicklythrough, you'll notice, that i'm not giving time for thething to finish animating, okay? and we're going to starttalking about animation in the week after next. and [pause] one thing aboutanimation is it's going to happen a littlebit out of band

with what's actually happening. so i am actuallyflipping here and all that flipping is happening, butthe animation is kind of slow and it's staying behind,and that's kind of just, unfortunately, the way it is, the animation will eventuallycatch up, but here we go to our last card, then we getfacedown, and now we click, and it's not clicking overand it's stopped at 104. okay? any questionsabout this solution?

pretty straightforward. again, elegance, simplicity,that's what you're shooting for in your homework, okay? big, overwrought solutions whereyou're adding a bunch of api and checking a lot of thingsare generally not preferred over more simplesolutions, so like this, even if you have something whereyou kind of have these two lines of code that aredoing the same thing, maybe shouldn't be replicatedlike this, it's a close call

as to the really perfectelegance, but i was going for simplicity heretoo because i only have so much time [laughing]. okay? >> alright. so now, we're going to gointo doing the next phase of our card matching game, which is to make thegame actually play. now the playing of thegame is part of our model.

it's really important tounderstand, it's not part of our controller,its part of our model. because i told you that themodel is the what your game is. well, what is this? it's a card matching game, sothe what better be in the model. so we're going to create aclass in our model that is going to encapsulate the logic of thegame playing and it's not going to know anything aboutuser interface, okay? it's not going to have anythings in it that have anything

to do with user interface and that's a reallyimportant distinction to make. so, let's create that new class, remember that we always createnew class the same way you did with your assignmenttoday by saying new file. okay? and we want anobjective-c class and i'm going to call it card matching[pause] game. okay? and it's going to inheritfrom nsobject as all of our kind of base classes do, andi'm going to put this thing

in the same directoryas the rest of my model and i'm also going toput it in the same group than the navigatoras my model, as well. okay? so it goes with all theseguys and it goes in this group. it's a nice thingto remember to do. alright? so we create it. here it is. okay? here's its header fileright here and i'm going to use this counterparts,automatic counterparts,

to show the implementation,okay? so there is its header fileand its implementation, and i always, when i designa new class, i always try to give my first crackat its public api first. okay? i'll go do itsimplementation later, but i want to kind of thinkof how are people going to use my class first? just to drive myoverall design, okay? and that's for asimple class like this,

if you get into a morecomplicated class, you might be having significantdesign meetings which are teamed to understand what's thisobject, how does it fit into the world, but ifyou're just doing a simple straightforward class, especially if you'redoing its first iteration, it sometimes nice to just thinkwhat is it's api, we call it, okay, api is the publicprogramming interface for a class.

so, i need to think of what thiscard matching game needs to do. well, one thing i know itneeds is an initializer. okay? and int. but when i think about mycard gap matching game, there's a couple of things itjust has to know to initialize. it can't just initialize itselflike a playing card deck can. a playing card deck knowseverything it needs to know about a playing carddeck when it's started, but this doesn'treally know that, so,

i need a couple of things. one thing i need is how manycards are we playing with? okay? how many cards are, is theperson allowed to match total? right? what's thetotal amount of cards? so we need that. so i'm going to say,int with card count, and we'll make an nsuinteger. really, that count has got to beat least two, you would think, so i'd probably, in myinitializer, should check

to make sure it'sgreater than one and if it's not i'llprobably return nil from self. in other words, iwon't initialize, my [inaudible] will return nil. okay? and we'll,actually, we'll pick one way where it does return nil, but weshould probably check that too. the second thing that i needis a deck, a deck of cards, because i got to dealthese cards out, right? i'm going to deal them out andthen you're going to be able

to pick some of them and do it. so, i'm going to say using deck. deck star deck. okay, so there's theinitializer, and, of course, to do that i need toimport deck, alright? so that's pretty good. start there. what else do i need for my game? well it's a game, so i thinkit should have a score.

[pause] eh, we'llsay nsinteger score. and, again, nsinteger, nsuinteger versus unsignedint is kind of a style thing, i used nsuinteger above,i'm going to use nsinteger to be consistent here and myscore can be negative possibly. so that's why it's not annsuinteger, it can be negative. and notice i made thisproperty read only. it's the first timewe've seen that. and why is that?

well that's becausei'm the game logic, i get to determinewhat the score is, nobody can set the score, itell you what the score is. therefore, there should beno setter for this property. at least not publicly. you're going to see ina moment, privately, we're going to make this rewrite so that we can setit privately, right? because we obviously need to beupdating our score all the time

as people flip these cardsover and get matches, they get points, weneed to update it. but publicly, we wantit to be a read only. okay? the only other thing ineed to do is someone's going to be clicking on these cards;they're going to be flipping over and being chosenand possibly matching, so i need some sort of methodto let somebody choose a card. so, i'm going to callthis choose card at index, nsuinteger, again, index.

so, there's a lot of waysin api you could have for letting someonechoose a card. the person who creates this cardmatching game, not the person, but the other object,like a controller that creates this modelclass, knows the count, because it specifiedthe counter cards. so, it's pretty reasonable tohave them specify an index, which means 0, inthis count minus 1, anytime someone chooses a card.

so this is just asimple way of specifying which card did the user choose? and similarly, i actually needto be able to return a card at a given index, andwhy do i need this? well, i need to be able tofind out the state of the game at any given time, i mean,how is my controller going to display a ui for thisgame if it can't, you know, if it can't find out whatthe cards, what the state of the cards is, so thisis just a little way for it

to get the cards, and it coulditerate through all the cards and get them all, and updatethem all, or it can get one in a particular indexand could kind of, whatever fits bestto what we're doing. alright, so, that'smy public api. now before i go and do myimplementation over here, you can see that i gotthis warning right here and what's this warning saying, it's saying there's actuallythree of them, you can click

on this little three by the way, it's saying you have notimplemented these [pause], these three methods thatyou made public, so that, that's a good warning. i need to go do that. but before i do that, i'm goingto go back to my controller, i want to show youhow we're going to, what kind of ui we're goingto have over here so that as we're doing ourimplementation, you can kind

of imagine how they'regoing to work together, but i actually wouldn'tnecessarily have to do the ui before i dothe card matching game and one could argue i shoulddo the card matching game first and not be influencedby the ui so much when i'm designing my model. okay? but, you know, this modelis going to be served by some ui so we're going to dothem at the same time so you can imagineit a little better.

so what do we need for this ui? well one thing is we need a lotmore cards, okay, this one card, it can't be matchedagainst anything else, so let's make more cards,this is very easy to do. i'm just going to move thiscard up into the corner here and i'm just going to copy andpaste it, so i can select it and copy and paste, okay? place it, use the niceblue guidelines there. i can even copy twoand paste them.

okay? or copy four,and paste them. okay? so now i'm goingto have 12 cards, that's a good number of cards. i actually don't need this flipsthing anymore, i'm not going to be just flipping cards, i'mgoing to be matching cards, i'm probably going to needsomething for the score which we'll do alittle bit later. but that's pretty much myentire ui, i'm just going to have these cards andi'm going to click on them,

it's going to show acard and then i'm going, i could either click on itagain to turn it back facedown, un-choose it, or i couldclick on another card and if it matches ishould get some points and if it doesn'tmatch, the other one, the last one i had isgoing to flip facedown. okay? now those of youwho are used to a game like concentration,it's a little different, usually you pick a card,then you pick another card,

and if they matchyou get points, if they don't match they usuallyboth turn back over, okay? which would be a cool ui,but i haven't taught you how to do animation and that'swhat you would need there because that second card, whenit comes up, would need to be on screen for a littlebit before they both went down because you got to atleast get to see this one. so since you don't haveanimation, when you click on that second one, it's going

to facedown the previousone if they don't match. okay? and then you justkeep clicking around trying to find matches and you getpoints, and we'll show you, kind of the point systemthat i'm going to use. so this is my entire ui. very, it's a verycontent-central ui, right? the ui is really focused onthese cards, there's not a lot of adornments andother stuff around it. and we're really not going tohave much other stuff except

for the score and you're goingto add like a redeal button and maybe a little bit ofstuff about some status about what's goingon in your homework, but this is the fundamentalbasis of the ui. okay? so now let's go backto our card matching game, and let's talk about how we'regoing to implement this thing. i'm going to go backto automatic here. get this thing back. just to make this look nicer,i'm going to go like that.

and i'm going to leave thisheader file up while we go and do the implementationso you can kind of see where we're shooting, thisis what we're shooting for. [pause] so, the firstthing i want to do is make this be readwritein my implementation only. and i do that with thislittle, private interface, remember i showed you aboutthis, that you can have one of these with the little openparentheses, close parentheses like that, and now you candeclare your own things.

well, i'm going toredeclare this thing to be nonatomic readwrite,nsinteger score. now this readwrite, wedon't use that very much because it's the default, right? is chosen, rememberthe properties chosen and match that are in card. those didn't say readwrite, butthey had a setter and a getter. okay? they were readwrite. we really only usethis when we're trying

to redeclare a readonlyone from public to private, this is about the onlytime we really use this. there are probablyprogramming styles where people putreadwrite all the time, even though it's the default,some people do that with strong since strong is the default. i like to specifystrong everywhere just so it's really clearwhat's going on in my mind. but readwrite, not necessaryfor most things except for here

where we're redefining it. so everyone understandwhat i'm doing here? this is score, this isexactly the same score, it's just that this saysthere's going to be a setter, but i'm only going to be able tocall that setter, at least not without a compiler warningin my implementation. okay, because i declaredthe readwrite part here. no public person is goingto be able to set the score, call set score, withoutcompiler giving a warning.

okay? so the next thing iwant to do is i want to think about my internal data structurefor my card game, really simple, it's just an array of cards. okay? i'm going tohave an array of cards, it's going to be this manycards, i'm going to pull them out of this deck, and,people are going to be able to choose those cards, someonecan go look at the cards, and we'll adjust the score aspeople choose the cards, okay? so i need that internal datastructure, it's internal,

so i'm going to put ithere, nonatomic, strong. it's going to be annsmutablearray, okay? and this is similar towhat we had in deck. alright? and i always like toput of card just to say what's in here because as we said,there's no way in objective-c to kind of have the compilerenforce what's in here. the things that are in thismutablearray are just objects. and the compiler does notknow what class they are. okay? so it's up to you to makesure you don't send messages

to things you pull outof it that are wrong. so here, we are trying to at least give the personreading our code know our intent, our intent is forthis to be an array of cards. okay? and, of course, wewant our lazy instantiation. [ typing sounds ] okay? so that's good. so now we have thisarray of cards, we can use it anytime we want.

again, we could dothis initialization in the initializer, right, wecan do this alloc init in here, but i happen to like using thelazy instantiation, i think it, it's kind of, makes the code in our initializerlook a little cleaner. so let's do our initializernext though. so i'm just going tocopy and paste here. you know, it probably notnecessary to copy and paste because if you juststart typing this,

it's going stay [inaudible], we'll do that withthe other method just to show you that one. and then we all know thatwe do this weird thing here, self equals superinit [phonetic]. now, this is our classesdesignated initializer, in other words, you haveto call this initializer or our class will notbe properly initialized, we can have other initializersthat could call this one, okay,

if there were ways todefault things or whatever. there is no way todo that, default it, so this has to be ourdesignated initializer, so, i'm actually goingto put a comment in my public headerfile saying this is my designated initializer. that way if anyone eversubclassed my card matching game, they would know that intheir designating initializer, they'd have to call super,our designated initializer.

okay, that's the waydesignated initializers work. you have to call your superdesignated initializer from your designatedinitializer. question? >> does the compilerknow that this is the. >> designated initializer? no, the compiler does not know. this is a purely commentedthing, it's similar to this kind of comment thing.

it's unfortunate thatthe compiler does not, there's no key word or anything that says this is mydesignated initializer. you had a question first here? okay, question? [ inaudible backgroundquestion ] well, followup with me, idon't understand the question. if you have otherinitializers, i guess the, your question is how do idisable another initializer?

right. oh, i see what you mean. yeah, you, okay, so thequestion is could i have another initializer, designatinginitializer not be public or something be private andhave things call from it? yeah, you absolutelycould do that, although if you make yourdesignating initializer not public, than subclassesdon't know about it because there's noprotected in objective-c, so anything subclassers needhas to be made public for them

to see it, it's still there,they can still subclass it, but, you know, to documentit you want it, you have to put itin your public api. so. yeah, the wholething with initializers in objective-c is less than nicely supportedby the language. yeah, so the question iswould it make sense here to, for me to implementan init here, right? to do something.

and actually it might wellmake sense to override an init, and you know what you would do? return nil. okay? because if you do cardmatching game alloc init [phonetic], it's notproperly initialized and there's no defaultfor the number of cards or the deck, so returnnil, okay? so, yeah, so the answeris yeah you could. alright, so just back toour designating initializer,

we need to call our supersdesignating initializer, which for nsobject is an init. no arguments. okay? then we just say if self,then we can initialize ourselves and then we're goingto return self. and if anything goeswrong in here, we will set self equal to nil. okay, and break outof this thing. and, in fact, somethingis going to go in wrong

in here, as you will see. okay? so, what do we need to doto initialize our thing here? well, we need to pull thismany cards out of this deck and put it in our internaldata structure here. alright? so how do we do that? how about four int i equals 0[pause], i is less than count, 5 plus, plus, sothat's just me going through this manyof these things. i'm going to say card star cardequals deck, draw random cards,

so i'm drawing arandom card of the deck, and then i'm just goingto say self dot cards, sub i, equals card, okay? so i've got this mutablearray,it's always going to be non-nil. so this is perfectly fine. okay? there's oneproblem here though. what if we run out of cards? okay? what if you passa playing card deck here and you say 100 cardsfor your game, okay?

this is going toeventually return nil. okay, and run out of cards. so we should checkhere and say if card, then we'll do what we normallydo, otherwise, self equals nil, break out of that fourloop because we're dead. okay? question? so the question is how can iaccess cards here to set it, in this line of code, when i haven't putanything in the cards?

well, card starts out as nil,and then when i call the getter, self dot cards righthere is the getter, it's going to initialize it to an empty array,but it's mutable. so i can add objects here,actually, oh i'm sorry. you're right about that,yeah, well, this is fine too, but maybe a better way to dothis is to say self dot cards at object card, becausethat's a little clearer. in fact, you might be right,that wouldn't have worked.

so, this is a betterway to do it, we just add cards to the deck. okay? make sense? sorry about that, i hada little different one. [pause] and actually i'mnot sure if that would work, let me think about that, soyou're saying insert object, yeah, that, actually thatprobably would work too. because you'd be doing insertobject at index, it wouldn't be, you know, it would be justat the end of the array,

that would probably work too. so you could do it either way. because self dot cardssub i, that sub i thing, it's really just callinga method, insert object at substring index, that'swhat the method is calling. you can look at thedocumentation to see the name themethod is calling there, but if you insert object atindex and it's at the end of the array, i believethat'll work.

but if you do it at 500,that's not going to work, okay? because it can only grow thearray as you go, i believe. so the question is can i putdifferent kinds of objects in the same array andthe answer is absolutely. you can and we do,occasionally, and we'll talk about on wednesday howyou deal with that. right? how, how wemanage the fact that we have different kindsof objects in there, but yes, absolutely, perfectly legal.

okay? alright. so there's that. and, again, as i said,we could probably say at the beginning here, ifself, we could also have an if count is lessthan two, right? then return nil, we could dothat, check that, as well. okay? okay, let's do someof our other methods here. how about choose card at index. okay? actually let'sdo card at index.

because card andindex is super easy. right? this is card star, andnotice if i start to type here, it knows that its card index soit's going [inaudible] press tab to get there, and this one itjust returns self dot cards of index. but, you know, thisis a public method. what happens if someonepasses a bad index there? right? an index that's greaterthan the count.

are we just going to goahead and crash here? one could argue thatmight be good, because we'll help find the bug. certainly some kind ofassertion in here would be good, we'll talk about that later,but i'm actually just going to protect myself againstit by saying if self, if this index is lessthan self dot cards count, then i'll return. okay? otherwise, oops, if,actually we'll do it this way,

use the old question mark. some people wereasking about this, okay? return question mark nil, everyone know thisquestion mark colon c thing, this is totally a c thing,nonobjective c thing, alright? just like an if then. yeah, question? >> so [inaudible], how doesarray access with these methods for the mutablearray to workwithout that index, if you,

or without the guard, ifyou pass the large index, would it necessarilycrash or would? >> yeah. so the question is, what if i pass too large anindex here, would this crash? and it would, and what wouldhappen is it would crash with the exception arrayindex out of bounds. [inaudible background question]no, no, it would crash, it, raise an exception, arrayindex out of bounds. okay? nsarray class would raisethat exception, and we'll talk

about raising exceptions. for now, until you goto this debugging thing, maybe on friday, for now, you'rejust going to see exceptions like that happen on yourconsole, it's not even going to stop where the exceptionhappened, which is unfortunate, but that debugging session,we'll talk about how to make it stop there, butthat's what's going to happen, it's going to raisean exception. so that's carded index,really, really easy.

and now let's talk about thisother one, choose carded index. this is really theheart of our logic. because here's whereyou're choosing the cards, here's where thematching actually has to happen, in the scoring, okay? so this is basically ourentire logic is going to be in this method. so what do we need here? well, they're choosing a card,

so let's get the cardthey chose, and i'm going to call self cardedindex, to get that card. okay, so now i havethe card that they, they're choosing here. now, if a card that theychose has already been matched against another card, theni'm going to do nothing here. i'm going to ignore when you try to choose a card that'salready been matched, successfully matched withanother card, so i'm just going

to say here, if card[pause] is matched, [pause] and actually i'll justsay if not card matched, we'll do something, otherwisewe'll just do nothing. okay? so i'm only going to matchthese cards if, or only going to try and matchtwo chosen cards if the card you just choseis not already matched. okay? does that make sense? does everyone seewhy we do that? it's already matched, you can'tmatch it against another one.

so now the question is ifthe card is already chosen, then what am i going to do? then i'm actually going toflip the card back over, un-choose it, so i'mgoing to say card dot is, dot chosen, rather, equals no. okay? so if you'd pick thecard that's already chosen and you choose it again,it's going to un-choose it. so it's kind of a toggle. choosing a card is kind ofa toggle thing, on and off.

notice that we havethe getter is chosen, remember we renamedit in our header file, with that getter equals ischosen, but the setter, okay, we don't use the is chosen. the setter is still chosen. chosen is the nameof the property. okay? everyone remember that? from card, hopefully, you hadto type it in so remember it. so otherwise we're inhere and in this case,

we're choosing anew card and we need to match it against other card. okay? let's say another card. now our matching gameonly matches two cards. in your homework, youhave to extend this game to match it to threecards, okay? that's going to be part ofyour homework assignment, but here we're only goingto match one other card. so all i need to do here islook through all the other cards

in my cards arrayup here, alright, this is my internaldata structure. i just need to look through themall and find, and go and see if there's another card thatis chosen and not matched. and if it is, i'm goingto try to match it against this cardthat was just chosen. so to search, i'm just goingto go through my cards, for card other card,in self dot cards. and we go throughall the other cards,

and if i can find another card that is chosen and is not matched,[pause], okay? then bingo! i found another cardto try and match. now, there can onlybe one other one, because i only do two cardmatches and i'm always looking for that second match,so, if it doesn't match, i'm going to flip that,un-choose that other one anyway. so, i'm ready to go here,

i basically found the only otherpossible card that can match. now, again, when you do a threecard match or an end-card match, if you so choosein your homework, which might be a good idea, you might find anumber of cards here. you might have to collect themsomehow in array or something so you can match themagainst each other, but here, i don't have to worryabout that. so i found this othercard that's also chosen,

let's match them. and i'm going to do that bysaying match score equals [pause] the card thatwe chose up here, right? this is the one thatthe user is choosing. match colon, rememberthat's our method in card that matches two cards. it takes an array though,an array, so i'm going to have make an array on the flyand put the other card in it. okay? everyone understandthis line of code?

i'm matching this card againstthis card using the match method in card. okay? but i had to createthis little array on the fly because match isactually capable of matching multiplecards, which is good because your homework'sgoing to require that. but here i'm only doing one,so i just create this little, blue at sign square bracketsthing to create an array. so now i've got this match.

now, we've defined match, kindof the semantics of match, are that if it returns non-zero, then there was amatch of some sort. if it returns zero, no match. okay? that's whatmatch colon means. okay, that's what wejust defined it that way in the semantics of our model. probably we should have puta comment in our card dot h that says match colon, returnzero if no match, otherwise,

how good a matchit is basically. so match should bereturning high scores if it's a really goodmatch and a lower score if it's not so good a match. you know, that's kindof the semantics of it. alright, so, what if it isa match or it's not a match. we have to deal withboth of those cases. alright, so in the casethat it is a match, then let's give ourselvesthat score.

[pause] okay? and, both these cards matched,so let's mark them both as matched, so we're going tosay card dot matched equals yes, and the other card dotmatched equals yes. alright? so they're matched, they're out of the game,we got some points. now what if they don'tmatch, well i told you if they don't match, i'm goingto turn that other chosen card, i'm going to un-choose it,basically, so i'm going

to say other carddot chosen equals no. okay? and also, ithink i'm going to impose a penaltyfor doing this, okay? i'm going to subtractsomething from the score, i'm going to call it mymismatched penalty here and i can make a constant. now, let's talk a littlebit about constants. you know, this is c. okay? so you're going to make theseconstants however you want.

one way to do it is to saypound sign defined, right? so i could say pound signdefined, mismatched penalty. and we can make themismatched penalty be, you know, the mismatched penalty, whatdid i decide, i think something like two, so i'm going to takeaway two points if you mismatch, so that's one way to do it. another way to doconstants is const, okay, its static const even. static const int mismatchedpenalty, if equals two.

okay? so that's anotherway to do it. this is kind of as you prefer. the nice thing about thesestatic const's is they're typed. right? whereas a poundsign defined is not typed, it's just substituting, okay? but here you've got to type inand you'll be able to see this in the debugger better. because it's typed. but it's really kindof your own thing,

i would just say beconsistent about what you choose to pound sign defineversus what you decide to make a static const. okay? totally up to you. you know, the other thingi'm going to do here is if you match, i actually, since i'm basically chargingyou two points if you mismatch, if you match i want togive you a lot of points, so i'm actually going togive you a match bonus.

match bonus. okay? and this is going tobe another constant here. put this up here, actually let'scopy and paste this over this, paste, and i'm going to giveyou four times whatever your matching is because i'm givingyou this penalty so i want to give you a bonusif you actually match. so whatever the match scoreis, however good a match it is, you're going to get four timesas many points if you match. okay? and these are thingsthat you would want to tweak

or maybe, like, possibly in yourhomework, you might even want to make these be public api toset these bonuses and penalties. okay? maybe that's somethingthat wants to be settable, but we're going tomake them constants for expediency in our game. the other thing we can dohere is if we find this match, right here, we canbreak out of this four. okay? and that's because we'rea two card matching game, once we found a match,we're, we're done, okay?

we found another chosen card,we processed it, we don't need to keep looking formatching cards. again, if you have,matching more than two and you're collecting cards,you may not be breaking out of this loop down here. the other thing iwanted to do here is if you are choosing the cardand flipping it face up, i want to make itcost something. so i'm actually going togive, make a cost to choose,

and i'm going tomake it be one point. okay, that's because i don'twant you to be able to just, you know, flip the cardover, flip it back down, flip the card over,flip it back down, you'd eventually memorize allthe cards and then flip them up and get all your matches. so it costs you a little bit. if you forget a cardand you flip it again, it's going to cost youjust a little bit, okay?

not as bad as mismatching, butit's going to cost you a little. question? [inaudible backgroundcomment] oh yeah, you're right. good call. see now i rely on all of you tomake sure i don't make mistakes like that, so yeah, absolutely. this break needs to be insidethis if because we only break out of this four whenwe find another card. good, good call. the last thing, of course,

is i want to markthis card as chosen. and sorry for the apps there. okay? this card [pause],woops, not is chosen, chosen, this card is chosen afterwe've done all of this thing. in any case, it'sgoing to be chosen, it's going to bethe new chosen card. okay? it might also bematched, but it's also chosen. okay? so, that's it, okay? that's the entire logicof my card matching game.

it's pretty simple, it's kindof in a way ultra-simplified. you can imagine much morecomplicated things, but, you know, i'm doing this onthe fly here and we only have, you know, an hour and15 for, for lecture, so, i've kept it kind ofintentionally simple, but the main point iwant you to understand from this logic isit has no ui in it. right? it's purely just dealingwith the cards and setting them to be matched or not,whether they're chosen or not,

depending on using thematch colon method, which is also part of our model. there's no ui here. okay? it's up to our controller to take this logicand turn it into ui. alright? so let'stake a look at that. i'm going to go back to our storyboard hereand make more space. move this over a little.

give me more space. okay. so, here's ourcontroller, right? our simple controller justas we had left it off, and i need to use thislogic in this thing. so the first thing i'm goingto do is create a property to hold my card matching game. okay? now, one could argue, somepeople would call this model, i don't like that so much, because sometimes a model willexpand multiple properties

or they might callit game model, okay? that's not so bad. i'm okay with that. i like game, i think it reads alittle nicer in the code, but, it's kind of a matterof personal preference, but in any case, i need to import my card matchinggame header file here, to make this work, and i'mgoing to lazily instantiate it. [pause] i'm just going to say ifthe game is nil, in other words,

just our object is freshlyinitialized, then i'm going to say game equals card matchinggame alloc, woops, game alloc, and then init [phonetic],okay there's two inits there, the one inherited fromnsobject which we know is going to return nil so idon't want that one, and init with card count. okay? so i'm going to dothat one, tab over here, how many cards are in this game? well there's 12.

so i should type 12 here right? [speaker makes noise] okay, no. that's like putting a 102 inyour homework solution, right? we might add more cards someday, we absolutely do not want 12here, so i'm going to put 0 here for now, and we'll, i'll showyou how we're going to figure out what this number is. and using deck, luckilyi have self-create deck, that's why i did that that way.

that's going to createmy, my deck. okay? then we'll returnunderbar game and it's nice and lazily initialized. okay? alright, so let's talkabout this zero right there. how are we going to find outhow many cards there are? well it turns out it'spossible to create an outlet to multiple things in your ui. remember that we have thisoutlet right here flips label, which was an outlet that wentto this little flip count thing,

that we had down here. it was a single outlet,which by the way, we can delete thissingle outlet. but it went to one object,the ui label, so let's get rid of that, and we don'tneed to put county there, we actually don't needdeck either, there's lots of stuff we can get rid of now. alright, so we're going to redothis whole thing, [inaudible]. we'll get rid ofthat in a second.

you can see our games gottensignificantly simpler now that the model's taking careof a lot of our stuff here and it's going to get evensimpler when we delete all this. but anyway, thatwas a single outlet. we can actually create anoutlet to multiple things, and as you might imagine,that outlet will be an array. okay? so how we do that? very simple. exact same way, i'm holdingdown the control key, okay?

pick the card here, i'm goingto hold down control and drag into my interface,just like i do with any other outlet i'm tryingto create, and when i let go, you can see that at the tophere where it says connection, there's actually the choice ofmaking an outlet collection. so that's an array of things. okay? we can also makean action messenger, we'd be declaring it here. or an outlet to a singlebutton, but here i'm going

to do an outlet collection, whenyou do outlet collection, xcode, not objective-c, but xcode wantsto know what kind of objects are in there, that's purelyfor xcode, there's, i told you there's no wayto know what's in an array in objective-c and thecompiler can't know that, so this is purely forxcode and you're going to see how xcode remembersthis answer in a second, and here's the name, i'mgoing to call it card buttons, that's what theseare, these are buttons

that are holding all the cards. notice it's not askingme strong or weak here. that's because thisproperty has to be strong. okay? and it has to be strong because while the viewhas a strong pointer to all these cards individually, the view does not have astrong pointer to this array. and if we did notmake this strong, than this would beconstantly being set to zero

because no one would havea strong pointer to it. okay? so, that's whythis has to be strong, because it's an array,it's not a button. now, this littlestuff right here, compiler completelyignores this, it's very much like ib action, it's just somestuff that xcode puts in there so that it knows that thisparticular property right here is an outlet collection,and you can see if i mouse over this it shows me the onebutton that i put in here.

now, i'd love to tell you wecan just select all of these and control drag,but you can't, okay? i've been asking forthat feature for years, but they never give it to me. so, i have to dragthese one-by-one, it's kind of unfortunate,but at least, you know, i drag it to the thing that'salready existing, and you notice as i get close, ithighlights the thing that is appropriate and, again,

it knows that because it knowsthis an outlet collection of buttons, so that's why ican highlight this property. okay? so i'm going tocollect all of them here, and when you do this, you know,it's somewhat error prone, you might miss, so it's niceto go back here and check, and you can see all12 buttons in here. question? [inaudiblebackground question] okay. great question! the question is doesthe order matter?

or is the order determined? and the answer is no. this order, the order of the object mirror iscompletely unknown to you, and you cannot depend on it. if you need the order,you're going to have to do this a different way. outlet collectionsare fundamentally, the order is not known.

okay? so no matter whatorder i control drag them, that's not going to bethe order in the array. okay? which was a good decisionby apple, it seems like oh, it'd be cool, but it'd bejust too hard for them to, to throw a lot of things inhere, it'd be too hard to show and you could get confused,so, you need to use something, a different mechanism,and you're going to learn many mechanismslater in this class that you could do this with.

this is just a prettysimple one right here. for a fairly smallnumbers of things. so anyway, we got thisconnection to these things. so now we can do card count. okay? we know thenumber of cards, we can just say selfdot card buttons, that's this propertyright here, alright? count. okay? so this is the number ofbuttons that's in this array.

okay? so that was good. that worked out well for us. okay? now we also have anice array of these buttons so that we can update them with what's happeningin the model, okay? so, first though, let'stalk about touching a card, when you touch on a card,what are we going to do, well we don't want todo any of this junk. okay? so we're just goingto rid of all of that.

okay? because we're goingto let the model handle it. so all we need to do to letthe model handle this is to get the card that thisbutton is associated with, because these buttons areall still sending this, if you look at this, see all 12of them are sending this action and the sender is still theactual button you touched on, not the array, butthe actual button, because this is the targetaction thing right here. so, we can still find outwho sending it and, in fact,

we can even find outit's index in this array by saying card index equalsself dot card buttons, index of object, sender, okay? so this is going to tell us where this sendingbutton is in this array. okay? so now that we knowwhich card it is in the array, we can just tell our game pleasechoose the card at that index. and we're just going to tell ourmodel, hey, choose that card. now, one thing herethough is choosing

that card might changethe state of the game. okay? it might cause somepoints or match some cards, a lot of things canchange, so we're going to put a little updateui here, okay? and this update ui method,which we're going to have to write has got to keep ourui in sync with the model. and remember that's one of the primary thingsa controller does, it syncs up the modelwith the ui.

okay? so let's go ahead andput a little thing here. update ui. okay. so what do we need to dowhen we're updating this ui? it's actually pretty simple,we're just going to go through all the cardbuttons, okay? get that card button,simultaneously look into the model for that card, and make sure the card buttonis showing what should be on that card.

so, let's go four uibutton, card button, in our card buttons, okay? so we're iteratingthrough all these buttons. card button is goingto be the variable. let's go ahead and get thatcard index, again, for, for the same thing, self dotcard buttons, index of object, the card button that isour iteration variable and we're cool withwhat we're doing there. alright? so we're justfiguring out which card it is.

then we're going to askour model, give us the card at that index, usingcard at index. so now we have the cardbutton and the card, awesome. now we can make sure thecard button reflects the card that goes along with it. okay? so, what do we needto set on the button? well, let's see, we have to setthe card buttons title, okay? so set title for stateui control state, control state normal.

okay? and we have to setthe background image, right? depending on whetherit's the stanford logo or the blank background. okay? also, if thecard is matched, i'm going to disable the button. okay? because you'vealready matched this card, you can't click on it anyway,so i'm going to disable it because a disabled buttonlooks a little different and i want buttons that arematched to look different.

yeah? >> [inaudible] card buttons,does that go from 0 to n? >> it does. so the question is does afast enumeration like this, when you do this four n thing,does that go from the zero to the n and theanswer, it does. it does go in order. [inaudible backgroundcomment] you could. so the question is doyou, do you not need this,

you could just haveanother iteration variable or you could use aniteration variable here, like four i equals0 to the length? you could. i don't like to depend onthat going from 0 to whatever, so that's why i used this here. it's a matter of style. totally a matter of style. this is also kindof a little clearer,

because here i'm saying iwant the card that goes with, you know, the card buttonthat goes with this thing. so, so the last thing i'm going to say is the card buttonenabled equals the card, not card is matched. okay? so, the card, thebutton will only be enabled if the card is not matched. okay, now of course ihave these two things, which i haven't [laughing]provided, right?

i've just left them, wedon't have that argument. and actually for both of those, i'm going to create little othermethods here, helper methods. so, i'm going, for the title, i'm going to have a helpermethod called title for card. it's going to take acard as the argument. and it's going to returnthe title of that card, and for the background i'mgoing to have ui image, background image for card.

[pause] hopefully as we'llgo along you'll start to see the namingconventions that we use. we often try to havethis last part of a name of a method before a colonindicate what we're looking for. so here we're looking for acard, so we try to make a thing. look at this one, button, right? this is a button. so we try to make thesearguments guide the reader towards what we'reasking for there.

we don't want to get toooverwrought about it, but it's a generalnaming convention there. so, what is the titleof a given card? so i have the card,what's its title? well, if the card ischosen, then i'm going to return the contentsof the card. if it's not, i'm going toreturn empty string or nil, so i'm just going to sayreturn card dot is chosen, question mark, car dotcontents, otherwise,

empty string let's say ornil, either one in this case. and how about thebackground image? this is kind of a cool one, i'mgoing to say return to ui image, image name is carddot is chosen, so if the card is chosen,then i want the card front, otherwise the card back, now youprobably think i'm just in love with this question markcolon [pause] syntax, which i do like it alot, it's kind of clean. but anyway, you understandwhat i'm doing here, right?

i'm actually havingthe name in here with the question markcolon nested inside, [inaudible] to getthe, the image. okay? so now, i canuse that here. let's do the title first. i'm just going to self,title for card, the card, and then here i'm going to sayself background image for card, card, and both of these i'mgoing to hit return just to make this a littleeasier to see.

okay? so, that's pretty much it. okay? i've matched up my uiwith my model, when i touch in the ui i let my modelknow to choose a card and we're prettymuch good to go. i think that's all i hadto show, yeah, we'll, we'll do the scorein a second here. we need to score, but beforewe do the score, let's go ahead and run this and makesure that it's working. okay, so when i click,hopefully i get a random card,

and when i click again,hopefully it continues to be the same card, okay? it'd be bad if that wasconstantly getting random card, but we know that wegot rid of that code so it's not going to do that. so there's a king,five, two, okay, now we got two clubs right here. so i could do that,oh, didn't match. okay? so why don't these match?

they should match. and the answer, anyonewant to tell me? yeah? [inaudible backgroundcomment] absolutely. the only match function wehave is this really bad match function, let's go look at it. it's right here in card, okay,this is the only match function that exists in ourentire application and it only says it's a matchif both cards are identical, well that's never goingto be true in our thing,

because we have adeck of 52 cards, every single one is different. so it's never going to match. so how do we deal with this? well we need to teach playingcard how to be a better matcher. okay? because cardsimplementation of match is simplynot sufficient. so what we're going to do iswe're going to override this, we use object-orientedprogramming,

that's what we're here for,so we're going to override it. let's go to playing card,here's playing card. now, notice the playingcard doesn't declare match in its public api. okay? it inherits it fromcard and i'm not going to redeclare it just becausei'm going to implement it. so i am going to go here andi'm going to re-implement match. okay? it knows that matchis method i inherit, that's why it was able toescape, complete it like that.

but i'm not going toput it in my public api and that's generallythe way we do it. okay? generally, if youinherit a method and you, a public method, and youoverride it, you don't have to put it in your header again. some stylistically wouldsay, yes, put it in there, so that someone knowsthat you override it. but most object-oriented peoplewould say you shouldn't have to know that you override it.

alright? this isobject-oriented programming. you should not haveto know that. that, that's implementationdetail that you happen to override match here. so, i'm a fan of the notputting match in playing card, it's already in playingcards public api because it inheritsit from card. alright, so what are wegoing to do in match? well, i'm going to havea really dumb match.

you're going to need abetter one for your homework. my dumb match only canmatch one other cards. okay? so and the firstthing i'm going to say here, let's go ahead and do in scoreequals zero and return score. the first thing i'mgoing to say is if other cards count[pause] equals one. okay? so i'm only goingto match one other card. okay? if there's twocards in there, no match. okay? too, too much for me.

so i'm just going tosay this one thing. now, i need thatother card though, how do i get the other card? i'm going to say cardstar other, in fact, i'm going to say playingcard star other card equals, and i could do alot of things here. i could say other cardssubzero, but i'm actually going to use a method here i want youto know called first object. other cards, first object.

okay, first object returnsthe first object in an array. if the array is empty,it returns nil. okay? that's different thansaying other cards subzero. because if that array isempty, that will crash. that will say arrayindex out of bounds. you see the difference? first object, there'salso a last object, they just have thismagic piece to them that they don't do arrayindex out of bounds.

okay?? but otherwise theyreturn the first object or nil if there are no objectsin there. i just want you to know that. i don't actually need that here, because i know there'sone object in that array. so this is not really necessary,i could say other card subzero, i'd be okay here,but i'm just trying to teach you the methodfirst object, that's all. so i got this other card.

so let's go ahead and matchit, what's a good match here? well, if the suits match, i'llgive a little bit of points, but if the ranks match, i'mgoing to give a lot of points, so, let's say if my [pause]self dot suit is equal to string the other card's suit. okay? so the suitsmatch, they're both clubs. then i'm going to say thescore equals one, okay? but, and we can say elseor not, because we're going to assume the cardsare all different.

so if the cards are thesame, then you're only going to get a suit match, whichdoesn't really make sense, but let's say if self dotrank, oops, we don't need to send a message there if selfdot rank equals the other cards rank, then let'sgive four points. now why do i givefour versus one? well, think of the math, right? if you have a club in your hand,how many other cards are there in a full deck thatwill match a club?

12. okay? if i have a king,how many other kings are there? three. okay? so 12 versus 3, it's four timeseasier to match that club, assuming you have a full deck. i'm just picking numberskind of at random here. it's, it's not a badchoice for the scoring here, but most times trying to getthese relative scoring right. question? [inaudiblebackground question] yeah, so the question is am i usingmagic numbering and absolutely.

and you probably, youknow, this whole thing of the scoring here issomewhat magic numbers in our simple implementation,you probably, although, [pause] this, okay, this isnot necessarily a magic number. if you define match to say makethe easiest match verse, verse, equal one, and then makeany more difficult matches to be multiplicatively, youknow, more difficult like this, than this is actually right,because that four is fundamental to a playing card,it's fundamental

to how a playing card ranksand suits work, alright? so, assuming you definethis match only match against other playingcards in this same deck, that four is magic, butit's magic to this class. so, yeah, you could puta pound sign define, but that doesn't make itany less of a magic number. so it is magic, but youcould put it in there. you see what i'm saying, seethe difference between that and like 102 in your controller,which is trying to be, you know,

maybe generic decks,that's a little different. good question though. alright, so now wehave a better match. so now if we go back to ourcontroller, so let's do that. just [inaudible] onscreen right here. and run. [pause] hopefully now, let's see if we canfind a match. okay, so there's a club,right, and this is a club so let's match them, ready?

oh! it matched! and it even disabled them. okay? but i have no ideahow many points i got because there's no scoreon here, so, obviously, we need a score, solet's put the score in. hopefully by now you can imagineeasily how we would do the score, simple, just like flips,we just grab a label here and then drop it down in here,i'm going to say score zero, because that's what i wanted,oops, that's what i wanted

to say when we start up. and yes, it's possible youcould load these strings up at start up, we'll talkabout when and where to do that in your code in thenext couple lectures. so i have this score, iobviously need to be able to talk to it, so icontrol drag up here into my interfaceto create an outlet. i let go, this onewants to be an outlet, not an outlet collection,but an outlet.

i'm going to call itscore label, okay? it can be weak because weknow that the view is going to point it, it is the ui label. there's an outlet for it. i'm just going toupdate it in update ui. so i'm going to say self dotscore label equals nsstring, string with format, we'llsay score colon percent d, and where do we get the score? [pause] anyone knowwhere we get the score?

from the game, exactly! from our model, selfdot game dot score. okay? now i'm goingto go show that just to make sure everyoneunderstands that. here's my card matching game, remember that in its publicapi, it has the score. okay? and we're keeping thescore when we're choosing. okay? everybody cool with that? so that's it.

that's all we need to dohere, to update the score. normally we have, oops, thisneeds score label dot text. sorry. alright, we need the textproperty of the ui label class and we're calling itsetter here, set text, this is basicallywhat's happening here and setting the score. okay? one other thingi'm going to do just in case the score is reallybig, so make that wide, and run. and we'll talk about, by theway, text fields that get larger

when you put text in them andstuff like that, there's a way to handle that in ios, aswell, we're not, we can't talk about it, everythingall at once though. alright, so let's see here. minus one. why did i get minus one? because i have a cost to flip. so every time i flip acard, i got to pay, alright? now here's a spade andhere's a spade, alright?

so what's going to be myscore after i click this? well, clicking this still goingto cost me one, so that's going to make my score go downto minus six, but i'm going to get one point formatching times my match bonus of four, is four more points. so my score should be minus two. alright? and it is! woohoo. okay, and let's see ifwe can find ranks that match. [pause] oh, there's asix and here's a six.

okay, so i'm going tomake these two match, so what's this going to be? alright, so we're at minus 9now, when i click this one, we're going to be at minus 10,but they're going to match. i'm going to get four points for the match times my matchbonus of four is 16 points. so i'm going to be at plus 6. everyone agree with that? and there we are,score plus six.

okay? alright, so that's it. that's as much as i'mgoing to do and i'm, we got some slideshere at the end, but that's it on the demo here. and your assignment isgoing to be to make it so you can match twocards or three cards, you can have a little switchor some sort of ui to choose between whether you're matchingtwo cards or three cards, and so that's goingto require some change

to your logic in your model. it's going to require a littlebit of ui and it's going to require your controllerto do a little bit of glue in between that. you're also going to be askedto add another label in here that says what's going on. so when i click this, itshould say you chose the seven of hearts. when i choose this, it shouldsay seven hearts and two

of clubs did not match, minus2, or something like that. okay? so, if you pick twothings that do match, like, [pause] those two hearts, itshould say four of hearts, seven of hearts matchfor whatever points. >> how would you testyour program on a device? >> how would youtest it on a device? okay, let's run thison a device actually. great question. so i have a device attachedover here, which you can see,

and it's asking me toupdate, which we're not going to do right now, and if youlook up at the top of xcode, you'll see that there's a bunch of different simulators youcan run on and you can also run on a device if you have itattached, and we're going to have a friday sectionprobably next week, or maybe the week after, wherewe're going to show you how to register your device ifyou don't know how to do that and get this all set up.

so this is a bit of apreview, but i'm going to actually run thison the ipad. so i just pick ipad, and hitrun, and it runs on the ipad. and i'm going to start doingthis for most of the demos, is running it ona device instead of running it in the simulator. it's a little nicer because thescreens a bit, little bigger as you can see, and sohere it is on my ipad here. and so i can tapand oop, it crashes.

oh, well, that's not good. what did i do wrong here? well, i don't know what idid wrong, but i messed it up when i preset this upso i'm sorry about that, but i will show you that, i'll start running all my demoshopefully on a device starting with next wednesday's thing and hopefully i won't makethis mistake, sorry about that. anyway, okay, so that's it.

any other questions about it? >> for more, pleasevisit us at stanford.edu.

Tidak ada komentar:

Posting Komentar