{"captions":[{"content":"[Seminar] [iOS: Writing Apps Like a Boss]","startTime":0,"duration":2000,"startOfParagraph":false},{"content":"[Tommy MacWilliam] [Harvard University]","startTime":2000,"duration":2000,"startOfParagraph":false},{"content":"[This is CS50.] [CS50.TV]","startTime":4000,"duration":4000,"startOfParagraph":false},{"content":"All right, everyone, welcome to iOS: Writing Apps like a Boss.","startTime":8000,"duration":4000,"startOfParagraph":true},{"content":"This seminar is going to focus on writing apps for the iPhone","startTime":12000,"duration":4000,"startOfParagraph":false},{"content":"and in turn writing apps for the iPad, and so we're basically going to walk through","startTime":16000,"duration":3000,"startOfParagraph":false},{"content":"a couple different examples of how to make an app, a simple game like Tic Tac Toe,","startTime":19000,"duration":4000,"startOfParagraph":false},{"content":"or if you're more interested in making an app like some kind of news reader","startTime":23000,"duration":3000,"startOfParagraph":false},{"content":"or something that interacts with the Internet I will talk about that as well.","startTime":26000,"duration":4000,"startOfParagraph":false},{"content":"Here's our brief agenda.","startTime":30000,"duration":2000,"startOfParagraph":false},{"content":"IOS apps are written in a language called Objective-C,","startTime":32000,"duration":4000,"startOfParagraph":true},{"content":"and so this is a little bit similar to C but not really at all,","startTime":36000,"duration":3000,"startOfParagraph":false},{"content":"so we'll be talking a little bit about the language itself","startTime":39000,"duration":2000,"startOfParagraph":false},{"content":"and then how to build iPhone apps using this app program called XCode,","startTime":41000,"duration":4000,"startOfParagraph":false},{"content":"which if you haven't downloaded it yet feel free to start the download now.","startTime":45000,"duration":3000,"startOfParagraph":false},{"content":"It's several gigabytes.","startTime":48000,"duration":2000,"startOfParagraph":false},{"content":"It should be free on the App Store, so you'll need to have a Mac","startTime":50000,"duration":4000,"startOfParagraph":false},{"content":"ideally running the latest version of OS X.","startTime":54000,"duration":3000,"startOfParagraph":false},{"content":"If you're not, no problem.","startTime":57000,"duration":2000,"startOfParagraph":false},{"content":"We have Macs in the science center available for your use","startTime":59000,"duration":3000,"startOfParagraph":false},{"content":"with XCode installed, and so feel free to use those for development.","startTime":62000,"duration":3000,"startOfParagraph":false},{"content":"If you want to make an app but don't have a Mac, don't worry.","startTime":65000,"duration":2000,"startOfParagraph":false},{"content":"There's plenty of campus resources for that.","startTime":67000,"duration":2000,"startOfParagraph":false},{"content":"And so then we're going to cover 2 larger examples of different apps you can make.","startTime":69000,"duration":6000,"startOfParagraph":false},{"content":"Objective-C is technically what's called a super set of C.","startTime":75000,"duration":4000,"startOfParagraph":false},{"content":"That means that any C code is also valid Objective-C code.","startTime":79000,"duration":5000,"startOfParagraph":false},{"content":"That means that we kind of duct taped on some additional features to C.","startTime":84000,"duration":5000,"startOfParagraph":false},{"content":"Some of these features include not having to ever write malloc again, thank God,","startTime":89000,"duration":4000,"startOfParagraph":false},{"content":"no having to worry about those stupid pointers and freeing them and all that stuff","startTime":93000,"duration":3000,"startOfParagraph":false},{"content":"you hated about C, and it's kind of gone in Objective-C.","startTime":96000,"duration":4000,"startOfParagraph":false},{"content":"Now, Objective-C also has a much larger standard library,","startTime":100000,"duration":3000,"startOfParagraph":true},{"content":"so there's a lot more functionality you get for free inside of Objective-C.","startTime":103000,"duration":4000,"startOfParagraph":false},{"content":"Remember when we were writing PHP we noticed that we went from ","startTime":107000,"duration":3000,"startOfParagraph":false},{"content":"this smallest language to the giant library of all these crazy things you can do.","startTime":110000,"duration":4000,"startOfParagraph":false},{"content":"The same thing happens in iOS.","startTime":114000,"duration":2000,"startOfParagraph":false},{"content":"There's objects for things like the Buddhist calendar, and really anything","startTime":116000,"duration":3000,"startOfParagraph":false},{"content":"you can possibly think of probably exists already in Objective-C's implementation.","startTime":119000,"duration":6000,"startOfParagraph":false},{"content":"The objective part of Objective-C is referencing something ","startTime":125000,"duration":3000,"startOfParagraph":false},{"content":"called Object-Oriented Programming.","startTime":128000,"duration":3000,"startOfParagraph":false},{"content":"This is kind of a new concept, but we've actually mostly learned ","startTime":131000,"duration":3000,"startOfParagraph":false},{"content":"a lot of these concepts already.","startTime":134000,"duration":3000,"startOfParagraph":false},{"content":"The idea behind Object-Oriented Programming is that you're going to structure","startTime":137000,"duration":2000,"startOfParagraph":false},{"content":"a lot of your code around these things called classes,","startTime":139000,"duration":4000,"startOfParagraph":false},{"content":"and these classes are really glorified structs.","startTime":143000,"duration":3000,"startOfParagraph":false},{"content":"Inside of a struct we basically said here is a thing,","startTime":146000,"duration":4000,"startOfParagraph":false},{"content":"and this thing can have members.","startTime":150000,"duration":2000,"startOfParagraph":false},{"content":"For example, a node in a linked list could have other things","startTime":152000,"duration":3000,"startOfParagraph":false},{"content":"like a value, a pointer to the next node in the list,","startTime":155000,"duration":3000,"startOfParagraph":false},{"content":"and together that pointer and that value composed this one instance of a struct.","startTime":158000,"duration":6000,"startOfParagraph":false},{"content":"Classes are very similar except ","startTime":164000,"duration":3000,"startOfParagraph":false},{"content":"classes can also have functions inside of them.","startTime":167000,"duration":3000,"startOfParagraph":false},{"content":"When we declared a struct, we could only say int n or node *next.","startTime":170000,"duration":4000,"startOfParagraph":false},{"content":"Now with Objective-C we can actually put functions","startTime":174000,"duration":3000,"startOfParagraph":true},{"content":"inside of those things.","startTime":177000,"duration":2000,"startOfParagraph":false},{"content":"Another thing that classes can do is they can inherit data from other classes.","startTime":179000,"duration":4000,"startOfParagraph":false},{"content":"For example, we'll be looking at a bunch of built-in Objective-C classes.","startTime":183000,"duration":4000,"startOfParagraph":false},{"content":"One of them could be the class that represents the view for a screen,","startTime":187000,"duration":4000,"startOfParagraph":false},{"content":"and so by saying I want to implement my own view","startTime":191000,"duration":3000,"startOfParagraph":false},{"content":"we basically say someone over at Apple, probably really nice people,","startTime":194000,"duration":4000,"startOfParagraph":false},{"content":"wrote this class for me, and it handles things like displaying buttons","startTime":198000,"duration":3000,"startOfParagraph":false},{"content":"or rendering the screen, and we would be really pained","startTime":201000,"duration":4000,"startOfParagraph":false},{"content":"to implement all that functionality ourselves, and so by simply","startTime":205000,"duration":3000,"startOfParagraph":false},{"content":"inheriting data we can say everything that you did in that class","startTime":208000,"duration":3000,"startOfParagraph":false},{"content":"I also want inside of my class, and then I'm going to do some other stuff,","startTime":211000,"duration":3000,"startOfParagraph":false},{"content":"namely implement an app.","startTime":214000,"duration":3000,"startOfParagraph":false},{"content":"That's what that word inheritance means. We'll see a more concrete example.","startTime":217000,"duration":3000,"startOfParagraph":false},{"content":"And finally, the key with Object-Oriented Programming is that ","startTime":220000,"duration":2000,"startOfParagraph":true},{"content":"it leads to data encapsulation.","startTime":222000,"duration":3000,"startOfParagraph":false},{"content":"In some of our problem sets we could have these big, global variables","startTime":225000,"duration":3000,"startOfParagraph":false},{"content":"and globals everywhere, and that's how we'd keep track of state.","startTime":228000,"duration":3000,"startOfParagraph":false},{"content":"With classes we can start encapsulating information inside of an object.","startTime":231000,"duration":4000,"startOfParagraph":false},{"content":"If we have one screen on our app, we don't really need to have any data from ","startTime":235000,"duration":3000,"startOfParagraph":false},{"content":"another screen in our app inside of that, ","startTime":238000,"duration":3000,"startOfParagraph":false},{"content":"and so by encapsulating things within classes this actually leads","startTime":241000,"duration":3000,"startOfParagraph":false},{"content":"to much better code design, and this is possible with some of the additional features","startTime":244000,"duration":4000,"startOfParagraph":false},{"content":"of Objective-C.","startTime":248000,"duration":3000,"startOfParagraph":false},{"content":"Forewarning, the syntax for Objective-C is bananas.","startTime":251000,"duration":4000,"startOfParagraph":false},{"content":"It is like nothing we've seen before,","startTime":255000,"duration":4000,"startOfParagraph":false},{"content":"so it is a little bit of a learning curve getting used to ","startTime":259000,"duration":3000,"startOfParagraph":false},{"content":"what the heck does this mean?","startTime":262000,"duration":2000,"startOfParagraph":false},{"content":"But once you get past that initial learning curve it's really, really smooth","startTime":264000,"duration":3000,"startOfParagraph":false},{"content":"to start writing apps.","startTime":267000,"duration":2000,"startOfParagraph":false},{"content":"To declare a class, to say here is my class, it exists,","startTime":269000,"duration":4000,"startOfParagraph":true},{"content":"and maybe here are some things that I'm going to define later,","startTime":273000,"duration":2000,"startOfParagraph":false},{"content":"I'm going to say @interface.","startTime":275000,"duration":3000,"startOfParagraph":false},{"content":"I'm going to say @interface. I'm going to give my class a name.","startTime":278000,"duration":3000,"startOfParagraph":false},{"content":"And then later somewhere else I'm going to say @end, ","startTime":281000,"duration":2000,"startOfParagraph":false},{"content":"and everything in between the @interface and the @end","startTime":283000,"duration":3000,"startOfParagraph":false},{"content":"is going to be my class.","startTime":286000,"duration":2000,"startOfParagraph":false},{"content":"That is going to be what's inside of our .h files.","startTime":288000,"duration":3000,"startOfParagraph":false},{"content":"Just like in C our .h files basically said here are some things that will exist.","startTime":291000,"duration":4000,"startOfParagraph":false},{"content":"I'm not necessarily telling you what they do yet,","startTime":295000,"duration":2000,"startOfParagraph":false},{"content":"but the compiler needs to know that they exist.","startTime":297000,"duration":2000,"startOfParagraph":false},{"content":"Later inside of our .m files—because m for Objective-C ","startTime":299000,"duration":5000,"startOfParagraph":false},{"content":"is where we're actually going to define what these classes do.","startTime":304000,"duration":4000,"startOfParagraph":false},{"content":"Much like our .c files, we provided an implementation for functions.","startTime":308000,"duration":3000,"startOfParagraph":false},{"content":"Inside of our .m file we're going to say here is what all of the functions","startTime":311000,"duration":4000,"startOfParagraph":false},{"content":"inside of my class—what they all do.","startTime":315000,"duration":3000,"startOfParagraph":false},{"content":"And finally, inside of a struct we could say inside of those curly braces","startTime":318000,"duration":4000,"startOfParagraph":false},{"content":"int n or node *next,","startTime":322000,"duration":3000,"startOfParagraph":false},{"content":"and in Objective-C we're going to use the keyword @property,","startTime":325000,"duration":3000,"startOfParagraph":false},{"content":"and this is what's going to define the properties, ","startTime":328000,"duration":3000,"startOfParagraph":false},{"content":"or the non-functions that are a part of my classes.","startTime":331000,"duration":5000,"startOfParagraph":false},{"content":"Calling functions in Objective-C is also bananas.","startTime":336000,"duration":4000,"startOfParagraph":true},{"content":"When we declared functions in C we said something like int foo ","startTime":340000,"duration":3000,"startOfParagraph":false},{"content":"and open paren and then gave it a list of arguments.","startTime":343000,"duration":3000,"startOfParagraph":false},{"content":"This is what declaring methods or functions looks like in Objective-C.","startTime":346000,"duration":5000,"startOfParagraph":false},{"content":"If I want to declare a function or a method ","startTime":351000,"duration":3000,"startOfParagraph":false},{"content":"where I'm saying method is really just a function that's a member of a class,","startTime":354000,"duration":4000,"startOfParagraph":false},{"content":"so kind of interchangeable, but not really,","startTime":358000,"duration":3000,"startOfParagraph":false},{"content":"so inside of my method I want to create a new method.","startTime":361000,"duration":2000,"startOfParagraph":false},{"content":"It's going to return nothing, so it's going to be of type void.","startTime":363000,"duration":3000,"startOfParagraph":false},{"content":"This is the return type of my function.","startTime":366000,"duration":2000,"startOfParagraph":false},{"content":"Now we have parens here because—I don't know.","startTime":368000,"duration":3000,"startOfParagraph":false},{"content":"Next is going to be the name of my function,","startTime":371000,"duration":3000,"startOfParagraph":false},{"content":"and then finally we have a semicolon just like we had in C.","startTime":374000,"duration":3000,"startOfParagraph":false},{"content":"What's new here is this guy here.","startTime":377000,"duration":2000,"startOfParagraph":false},{"content":"This hyphen is actually necessary, and what this says is that","startTime":379000,"duration":3000,"startOfParagraph":false},{"content":"this method here must be called on an instance of a class.","startTime":382000,"duration":4000,"startOfParagraph":false},{"content":"After we declared our structs we probably said something like","startTime":386000,"duration":3000,"startOfParagraph":true},{"content":"struct node n, and that actually created","startTime":389000,"duration":3000,"startOfParagraph":false},{"content":"or instantiated one of those structs so that I could actually start working","startTime":392000,"duration":3000,"startOfParagraph":false},{"content":"with what's inside of it, so this dash means that we have to ","startTime":395000,"duration":3000,"startOfParagraph":false},{"content":"instantiate the class just like we instantiated that struct","startTime":398000,"duration":3000,"startOfParagraph":false},{"content":"before we can call this method on it.","startTime":401000,"duration":2000,"startOfParagraph":false},{"content":"If I want to start adding arguments to my methods ","startTime":403000,"duration":3000,"startOfParagraph":false},{"content":"it gets even more bananas.","startTime":406000,"duration":2000,"startOfParagraph":false},{"content":"Here's my method name. ","startTime":408000,"duration":2000,"startOfParagraph":false},{"content":"Then I'm going to have a colon, and after this colon it says here comes some arguments.","startTime":410000,"duration":3000,"startOfParagraph":false},{"content":"This method takes one argument.","startTime":413000,"duration":3000,"startOfParagraph":false},{"content":"The type of its argument is an int, and the name of that argument","startTime":416000,"duration":3000,"startOfParagraph":false},{"content":"or the variable that I'm going to start using inside of the method is called i.","startTime":419000,"duration":4000,"startOfParagraph":false},{"content":"Again, this is method. It takes one argument.","startTime":423000,"duration":2000,"startOfParagraph":false},{"content":"If you want to start adding more arguments it gets more bananas","startTime":425000,"duration":5000,"startOfParagraph":true},{"content":"in that we have this colon that says here comes my list of arguments.","startTime":430000,"duration":3000,"startOfParagraph":false},{"content":"This first argument is an integer.","startTime":433000,"duration":2000,"startOfParagraph":false},{"content":"Now, this second argument is interesting.","startTime":435000,"duration":2000,"startOfParagraph":false},{"content":"The variable that I'm going to be using inside of my function ","startTime":437000,"duration":3000,"startOfParagraph":false},{"content":"is called f, so inside of my function I could say ","startTime":440000,"duration":3000,"startOfParagraph":false},{"content":"f + = 1 or something.","startTime":443000,"duration":2000,"startOfParagraph":false},{"content":"This thing here is basically a key for that argument or parameter.","startTime":445000,"duration":5000,"startOfParagraph":false},{"content":"Just like we had key value pairs and something like JSON or associative arrays","startTime":450000,"duration":4000,"startOfParagraph":false},{"content":"Objective-C made the decision to say, okay, just so that it's really clear","startTime":454000,"duration":3000,"startOfParagraph":false},{"content":"when you call a method what all these parameters are","startTime":457000,"duration":2000,"startOfParagraph":false},{"content":"I'm actually going to name them all.","startTime":459000,"duration":2000,"startOfParagraph":false},{"content":"When you call a method, you'll actually say andFloat,","startTime":461000,"duration":4000,"startOfParagraph":false},{"content":"and then you'll pass it in.","startTime":465000,"duration":2000,"startOfParagraph":false},{"content":"Interestingly, this one is not named, but all of the other parameters are,","startTime":467000,"duration":3000,"startOfParagraph":true},{"content":"so if we had a 3rd argument I could say andFloat","startTime":470000,"duration":3000,"startOfParagraph":false},{"content":"and another float and so on.","startTime":473000,"duration":3000,"startOfParagraph":false},{"content":"When I call these methods it is of course bananas,","startTime":476000,"duration":5000,"startOfParagraph":false},{"content":"so if I have an object, and I defined a method called foo,","startTime":481000,"duration":3000,"startOfParagraph":false},{"content":"and I want to call it, rather than saying foo open/close parens","startTime":484000,"duration":5000,"startOfParagraph":false},{"content":"I'm going to open a bracket.","startTime":489000,"duration":2000,"startOfParagraph":false},{"content":"Here's the name of my method.","startTime":491000,"duration":2000,"startOfParagraph":false},{"content":"I'm going to close the bracket, and this is the object I'm calling it on.","startTime":493000,"duration":4000,"startOfParagraph":false},{"content":"Remember, all of these methods exist within classes","startTime":497000,"duration":3000,"startOfParagraph":false},{"content":"because classes can have methods defined inside of them.","startTime":500000,"duration":3000,"startOfParagraph":false},{"content":"Here I've arbitrarily created an object of some class,","startTime":503000,"duration":3000,"startOfParagraph":true},{"content":"and this is the syntax for doing that.","startTime":506000,"duration":2000,"startOfParagraph":false},{"content":"There are 2 steps to creating an object.","startTime":508000,"duration":3000,"startOfParagraph":false},{"content":"The first step is to say I want to allocate space.","startTime":511000,"duration":3000,"startOfParagraph":false},{"content":"This is the equivalent of a malloc. We don't have to say malloc anymore.","startTime":514000,"duration":3000,"startOfParagraph":false},{"content":"We dropped the m, made it alloc, and replaced the .c with .m.","startTime":517000,"duration":5000,"startOfParagraph":false},{"content":"After we alloc something we then need to initialize it.","startTime":522000,"duration":5000,"startOfParagraph":false},{"content":"Basically when you create objects you might want to have some logic ","startTime":527000,"duration":2000,"startOfParagraph":false},{"content":"that executes when they're created, so you can pass in some default values","startTime":529000,"duration":4000,"startOfParagraph":false},{"content":"or something like that, and so this init method is what actually creates the object.","startTime":533000,"duration":4000,"startOfParagraph":false},{"content":"We first allocate space, just like we did in C, ","startTime":537000,"duration":2000,"startOfParagraph":false},{"content":"and then we initialize it, which may or may not do a whole lot.","startTime":539000,"duration":5000,"startOfParagraph":false},{"content":"Then we're returning this thing into an object o.","startTime":544000,"duration":3000,"startOfParagraph":false},{"content":"There's a star here because this is technically a pointer,","startTime":547000,"duration":2000,"startOfParagraph":false},{"content":"but don't worry, pointers aren't that big a deal in Objective-C anymore.","startTime":549000,"duration":3000,"startOfParagraph":false},{"content":"Now we've instantiated this class called NSObject,","startTime":552000,"duration":3000,"startOfParagraph":true},{"content":"and this is just a random class that Apple has.","startTime":555000,"duration":4000,"startOfParagraph":false},{"content":"We've instantiated this, and now I have an instance of this class","startTime":559000,"duration":3000,"startOfParagraph":false},{"content":"in this object o, so that means that if I defined","startTime":562000,"duration":3000,"startOfParagraph":false},{"content":"these methods I could call them like this.","startTime":565000,"duration":4000,"startOfParagraph":false},{"content":"Similarly, if I wanted to call a method with one argument, ","startTime":569000,"duration":2000,"startOfParagraph":false},{"content":"so this is the bar method, that takes one argument,","startTime":571000,"duration":3000,"startOfParagraph":false},{"content":"and here is the baz: qux method, so this takes 2 arguments.","startTime":574000,"duration":4000,"startOfParagraph":false},{"content":"This is calling one function on this object o.","startTime":578000,"duration":6000,"startOfParagraph":false},{"content":"Make sense?","startTime":584000,"duration":2000,"startOfParagraph":false},{"content":"The syntax should make sense, but you kind of get used to it.","startTime":586000,"duration":4000,"startOfParagraph":false},{"content":"Okay, let's talk about a few things that are built into Objective-C ","startTime":590000,"duration":4000,"startOfParagraph":true},{"content":"that weren't necessarily built into C.","startTime":594000,"duration":2000,"startOfParagraph":false},{"content":"In C we kind of had to deal with strings as these stupid character arrays,","startTime":596000,"duration":3000,"startOfParagraph":false},{"content":"and it got really annoying.","startTime":599000,"duration":2000,"startOfParagraph":false},{"content":"Objective-C has those all built in for us, and it's built in","startTime":601000,"duration":3000,"startOfParagraph":false},{"content":"using this class called NSString.","startTime":604000,"duration":2000,"startOfParagraph":false},{"content":"When I want to create an NSString we have more arcane syntax.","startTime":606000,"duration":4000,"startOfParagraph":false},{"content":"Rather than saying \"cs50\" we say @\"cs50\"","startTime":610000,"duration":5000,"startOfParagraph":false},{"content":"and this is just the syntax for declaring strings in Objective-C.","startTime":615000,"duration":2000,"startOfParagraph":false},{"content":"This is extremely easy to forget, so don't.","startTime":617000,"duration":4000,"startOfParagraph":false},{"content":"Now, once I have this, this is a string, but notice","startTime":621000,"duration":3000,"startOfParagraph":false},{"content":"it's really just an object.","startTime":624000,"duration":2000,"startOfParagraph":false},{"content":"I said NSString, which means I instantiated the class","startTime":626000,"duration":4000,"startOfParagraph":false},{"content":"called NSString, which someone else wrote for me,","startTime":630000,"duration":2000,"startOfParagraph":false},{"content":"and they were very nice about it, and so now","startTime":632000,"duration":3000,"startOfParagraph":false},{"content":"I can start calling methods on it.","startTime":635000,"duration":2000,"startOfParagraph":false},{"content":"If I call the method length on this object s","startTime":637000,"duration":3000,"startOfParagraph":false},{"content":"it's going to return to me the length of the string.","startTime":640000,"duration":3000,"startOfParagraph":false},{"content":"This is just like strlen in C.","startTime":643000,"duration":2000,"startOfParagraph":false},{"content":"This would return 4.","startTime":645000,"duration":2000,"startOfParagraph":false},{"content":"Similarly, another method I might want to care about is this characterAtIndex.","startTime":647000,"duration":4000,"startOfParagraph":true},{"content":"This is a method that says on this string s","startTime":651000,"duration":3000,"startOfParagraph":false},{"content":"I want you to get the zeroth character,","startTime":654000,"duration":3000,"startOfParagraph":false},{"content":"and so this would return to me the character c,","startTime":657000,"duration":2000,"startOfParagraph":false},{"content":"and there's a whole bunch more of these methods that you can Google really easily.","startTime":659000,"duration":3000,"startOfParagraph":false},{"content":"Apple's documentation is great, and we'll take a look at that in a bit.","startTime":662000,"duration":5000,"startOfParagraph":false},{"content":"Those are strings. ","startTime":667000,"duration":2000,"startOfParagraph":false},{"content":"We also have variable size arrays built in.","startTime":669000,"duration":2000,"startOfParagraph":false},{"content":"Remember in C when we declared an array","startTime":671000,"duration":2000,"startOfParagraph":false},{"content":"we had to say you have 5 elements, end of story.","startTime":673000,"duration":3000,"startOfParagraph":false},{"content":"When we got to JavaScript and PHP we could start ","startTime":676000,"duration":2000,"startOfParagraph":false},{"content":"doing things like adding elements or moving elements.","startTime":678000,"duration":2000,"startOfParagraph":false},{"content":"We can do the same in Objective-C.","startTime":680000,"duration":2000,"startOfParagraph":false},{"content":"Rather than create an array in the normal C way","startTime":682000,"duration":4000,"startOfParagraph":false},{"content":"we have again another class called NSMutableArray.","startTime":686000,"duration":4000,"startOfParagraph":false},{"content":"There's also NSArray,","startTime":690000,"duration":3000,"startOfParagraph":false},{"content":"and this is going to basically encapsulate some array.","startTime":693000,"duration":2000,"startOfParagraph":false},{"content":"This says the first thing I want to do is I want to allocate","startTime":695000,"duration":3000,"startOfParagraph":false},{"content":"space for a new array, and after I allocate it","startTime":698000,"duration":3000,"startOfParagraph":false},{"content":"I then need to initialize it.","startTime":701000,"duration":2000,"startOfParagraph":false},{"content":"Again, just calling these 2 methods.","startTime":703000,"duration":2000,"startOfParagraph":false},{"content":"Now this means that inside of this object a","startTime":705000,"duration":3000,"startOfParagraph":false},{"content":"I have an empty array sitting there.","startTime":708000,"duration":2000,"startOfParagraph":false},{"content":"If I want to add something to this array, I can call the addObject method.","startTime":710000,"duration":4000,"startOfParagraph":false},{"content":"I want to add an object to the array a, and I want to add the string CS50.","startTime":714000,"duration":5000,"startOfParagraph":false},{"content":"If I wanted to conversely remove that I can say I want to","startTime":719000,"duration":3000,"startOfParagraph":false},{"content":"remove the object at the first place on the array or object a.","startTime":722000,"duration":7000,"startOfParagraph":false},{"content":"Make sense?","startTime":729000,"duration":2000,"startOfParagraph":true},{"content":"Okay, you kind of get used to this square bracket thing.","startTime":731000,"duration":3000,"startOfParagraph":false},{"content":"By the way, inside of a lot of Apple's libraries you'll see this NS.","startTime":734000,"duration":4000,"startOfParagraph":false},{"content":"The NS actually stands for next step, which was one of Steve Jobs first companies,","startTime":738000,"duration":3000,"startOfParagraph":false},{"content":"and that's where he really started writing a lot of the code ","startTime":741000,"duration":3000,"startOfParagraph":false},{"content":"as kind of the basis for Mac OS X and all of the other stuff,","startTime":744000,"duration":3000,"startOfParagraph":false},{"content":"and so this NS is kind of this nice legacy shout out to one of the earlier companies","startTime":747000,"duration":5000,"startOfParagraph":false},{"content":"back when Apple was first starting out.","startTime":752000,"duration":2000,"startOfParagraph":false},{"content":"It's everywhere.","startTime":754000,"duration":2000,"startOfParagraph":false},{"content":"Let's take a look at a more holistic Objective-C example.","startTime":756000,"duration":5000,"startOfParagraph":false},{"content":"Here I am inside of XCode.","startTime":761000,"duration":3000,"startOfParagraph":false},{"content":"To get here, I first downloaded XCode from the App Store,","startTime":764000,"duration":3000,"startOfParagraph":false},{"content":"opened it up, and then I went up here to file,","startTime":767000,"duration":3000,"startOfParagraph":false},{"content":"over here to new, and then project.","startTime":770000,"duration":4000,"startOfParagraph":false},{"content":"After I do that I have all these options of what I want to create,","startTime":774000,"duration":3000,"startOfParagraph":false},{"content":"and so we'll take a look at these options later,","startTime":777000,"duration":2000,"startOfParagraph":false},{"content":"but just for this example, because we're not actually going to have an app yet,","startTime":779000,"duration":4000,"startOfParagraph":false},{"content":"I came down here, and I said Command Line Tool,","startTime":783000,"duration":3000,"startOfParagraph":false},{"content":"and this is an app that I could run at the command line","startTime":786000,"duration":3000,"startOfParagraph":false},{"content":"just like we've been running from C.","startTime":789000,"duration":3000,"startOfParagraph":false},{"content":"That's how I created this project, and so now I'm here,","startTime":792000,"duration":4000,"startOfParagraph":false},{"content":"so let's first look at this file, and this should look pretty familiar.","startTime":796000,"duration":4000,"startOfParagraph":false},{"content":"I have an int name. There's my friend argc, my other buddy argv.","startTime":800000,"duration":4000,"startOfParagraph":false},{"content":"And so we can see that this is the entry point for my first Objective-C application.","startTime":804000,"duration":6000,"startOfParagraph":false},{"content":"Here we can ignore this for now.","startTime":810000,"duration":2000,"startOfParagraph":false},{"content":"This is basically some memory management stuff that you won't really ","startTime":812000,"duration":3000,"startOfParagraph":false},{"content":"ever have to worry about.","startTime":815000,"duration":2000,"startOfParagraph":false},{"content":"Let's look at this first block here.","startTime":817000,"duration":2000,"startOfParagraph":true},{"content":"This first line, if I say Student* alice = [[Student alloc] init] what's that doing?","startTime":819000,"duration":7000,"startOfParagraph":false},{"content":"This first student here, this is probably a class.","startTime":826000,"duration":4000,"startOfParagraph":false},{"content":"This isn't a class that Apple wrote, but it's a class that I wrote.","startTime":830000,"duration":4000,"startOfParagraph":false},{"content":"The first thing I want to do is I want to allocate space for a new student,","startTime":834000,"duration":3000,"startOfParagraph":false},{"content":"and then I want to initialize it, so this gives me back","startTime":837000,"duration":3000,"startOfParagraph":false},{"content":"this new student object, and I'm storing this in a variable called Alice.","startTime":840000,"duration":5000,"startOfParagraph":false},{"content":"Where did that class come from?","startTime":845000,"duration":2000,"startOfParagraph":false},{"content":"Well, over here on the left side these are all of the different files inside of my project.","startTime":847000,"duration":5000,"startOfParagraph":false},{"content":"We can see here I have a Student.h and a Student.m.","startTime":852000,"duration":4000,"startOfParagraph":false},{"content":"The .h file, remember, is where I declare all of the things","startTime":856000,"duration":4000,"startOfParagraph":false},{"content":"that will exist within the class.","startTime":860000,"duration":2000,"startOfParagraph":false},{"content":"Let's take a look at that.","startTime":862000,"duration":3000,"startOfParagraph":true},{"content":"All right, here we have this @interface, and this says that here comes","startTime":865000,"duration":4000,"startOfParagraph":false},{"content":"the declarations of everything that will exist within my class.","startTime":869000,"duration":4000,"startOfParagraph":false},{"content":"Then I have a colon. Then I have this NSObject thing.","startTime":873000,"duration":3000,"startOfParagraph":false},{"content":"This colon signifies that inheritance bit we were discussing a little bit earlier.","startTime":876000,"duration":4000,"startOfParagraph":false},{"content":"This says everything an NSObject can do ","startTime":880000,"duration":3000,"startOfParagraph":false},{"content":"where NSObject is this class written by somebody else,","startTime":883000,"duration":3000,"startOfParagraph":false},{"content":"everything this NSObject can do I want to be able to do that.","startTime":886000,"duration":4000,"startOfParagraph":false},{"content":"By saying :NSObject that means that I basically","startTime":890000,"duration":4000,"startOfParagraph":false},{"content":"inherited all of the functionality of another class.","startTime":894000,"duration":4000,"startOfParagraph":false},{"content":"That really gave me a whole bunch of different methods and properties that I can use.","startTime":898000,"duration":4000,"startOfParagraph":false},{"content":"Down here I'm creating 2 properties.","startTime":902000,"duration":3000,"startOfParagraph":false},{"content":"That means my student, if this were a struct, these would be the 2 things","startTime":905000,"duration":3000,"startOfParagraph":false},{"content":"inside of my struct, so every student has a name","startTime":908000,"duration":3000,"startOfParagraph":false},{"content":"that is a string, and a student also has a grade,","startTime":911000,"duration":3000,"startOfParagraph":false},{"content":"which is an int.","startTime":914000,"duration":3000,"startOfParagraph":false},{"content":"Finally, down here I'm going to create a method for my student.","startTime":917000,"duration":6000,"startOfParagraph":true},{"content":"I called my method, initWithName, and it takes one argument,","startTime":923000,"duration":3000,"startOfParagraph":false},{"content":"and that argument is a string, and I called it name.","startTime":926000,"duration":5000,"startOfParagraph":false},{"content":"Now let's look at how we actually implemented this class.","startTime":931000,"duration":4000,"startOfParagraph":false},{"content":"Here, now I'm inside of my .m file, ","startTime":935000,"duration":3000,"startOfParagraph":false},{"content":"m for implementation, I guess.","startTime":938000,"duration":2000,"startOfParagraph":false},{"content":"I have my implementation, my end, and here is where I'm actually defining","startTime":940000,"duration":4000,"startOfParagraph":false},{"content":"what initWithName does.","startTime":944000,"duration":3000,"startOfParagraph":false},{"content":"I have initWithName, the name of my parameter, and then this","startTime":947000,"duration":3000,"startOfParagraph":false},{"content":"is where I'm actually creating a student,","startTime":950000,"duration":3000,"startOfParagraph":false},{"content":"and so this is a little bit cryptic, but this is kind of boilerplate ","startTime":953000,"duration":3000,"startOfParagraph":false},{"content":"that you want to include in your constructors.","startTime":956000,"duration":2000,"startOfParagraph":false},{"content":"This initialization function here, initWithName, is a type of constructor.","startTime":958000,"duration":4000,"startOfParagraph":false},{"content":"You're basically constructing a new student object","startTime":962000,"duration":3000,"startOfParagraph":false},{"content":"and maybe sending some data inside of it.","startTime":965000,"duration":2000,"startOfParagraph":false},{"content":"The first thing I want to do is I want to call init on this super thing.","startTime":967000,"duration":4000,"startOfParagraph":false},{"content":"Remember that when I said back here in the .h file ","startTime":971000,"duration":4000,"startOfParagraph":true},{"content":"that everything an NSObject has a student also has.","startTime":975000,"duration":6000,"startOfParagraph":false},{"content":"That means when I create a student what I also need to do is ","startTime":981000,"duration":3000,"startOfParagraph":false},{"content":"make sure that the NSObject that I'm inheriting all of that data from","startTime":984000,"duration":4000,"startOfParagraph":false},{"content":"is also initialized properly.","startTime":988000,"duration":4000,"startOfParagraph":false},{"content":"What I need to say is this super is actually going to refer to the parent class","startTime":992000,"duration":4000,"startOfParagraph":false},{"content":"that I'm inheriting from, so I want to make sure I initialize","startTime":996000,"duration":3000,"startOfParagraph":false},{"content":"everything that I'm depending on before I start trying to use it.","startTime":999000,"duration":4000,"startOfParagraph":false},{"content":"Then if that initialized correctly this is just like saying if malloc","startTime":1003000,"duration":3000,"startOfParagraph":false},{"content":"did not return null then I can start setting some properties.","startTime":1006000,"duration":4000,"startOfParagraph":false},{"content":"In JavaScript and PHP we had this keyword called this,","startTime":1010000,"duration":4000,"startOfParagraph":true},{"content":"and this referred to the current instance of a class.","startTime":1014000,"duration":4000,"startOfParagraph":false},{"content":"In Objective-C we call this self.","startTime":1018000,"duration":2000,"startOfParagraph":false},{"content":"When I say self.name, that means that the object","startTime":1020000,"duration":4000,"startOfParagraph":false},{"content":"I just created when I said student alloc init,","startTime":1024000,"duration":3000,"startOfParagraph":false},{"content":"that's going to give me back an object.","startTime":1027000,"duration":2000,"startOfParagraph":false},{"content":"That means I want to set the name of that object","startTime":1029000,"duration":3000,"startOfParagraph":false},{"content":"to whatever I just passed in.","startTime":1032000,"duration":3000,"startOfParagraph":false},{"content":"Just like in C, we access members with this dot,","startTime":1035000,"duration":3000,"startOfParagraph":false},{"content":"so self.name says the name of the student object","startTime":1038000,"duration":3000,"startOfParagraph":false},{"content":"is now going to be whatever you just passed in.","startTime":1041000,"duration":3000,"startOfParagraph":false},{"content":"And so finally, I can return it so I actually get something back.","startTime":1044000,"duration":4000,"startOfParagraph":false},{"content":"Questions?","startTime":1048000,"duration":2000,"startOfParagraph":true},{"content":"Okay, so this self = super init,","startTime":1050000,"duration":4000,"startOfParagraph":false},{"content":"if you don't totally understand the inheritance stuff don't worry.","startTime":1054000,"duration":3000,"startOfParagraph":false},{"content":"Just know that if you ever want to make your own init method just ","startTime":1057000,"duration":3000,"startOfParagraph":false},{"content":"do that, and you'll be good to go.","startTime":1060000,"duration":2000,"startOfParagraph":false},{"content":"Yeah.>>[Student] What does if self mean?","startTime":1062000,"duration":2000,"startOfParagraph":false},{"content":"This means when we malloc something we always checked if it was equal to null,","startTime":1064000,"duration":5000,"startOfParagraph":false},{"content":"and if it was null, then we exited.","startTime":1069000,"duration":2000,"startOfParagraph":false},{"content":"This is the same thing, because if this returns null, then we're probably going to seg fault","startTime":1071000,"duration":4000,"startOfParagraph":false},{"content":"if we start trying to manipulate it.","startTime":1075000,"duration":2000,"startOfParagraph":false},{"content":"That's our student class.","startTime":1077000,"duration":4000,"startOfParagraph":false},{"content":"That means we can initialize our students in one of two ways.","startTime":1081000,"duration":2000,"startOfParagraph":false},{"content":"If I say student alloc init I'm not using that method that I just wrote,","startTime":1083000,"duration":5000,"startOfParagraph":false},{"content":"and instead I can simply say alice.name, ","startTime":1088000,"duration":3000,"startOfParagraph":false},{"content":"and now I'm going to set that property name.","startTime":1091000,"duration":3000,"startOfParagraph":false},{"content":"Similarly, if I want to use that initWithName method","startTime":1094000,"duration":3000,"startOfParagraph":true},{"content":"I can simply say alloc, and then rather than saying init","startTime":1097000,"duration":3000,"startOfParagraph":false},{"content":"I'm going to call that method that I just created, and I'm going to pass in Bob.","startTime":1100000,"duration":4000,"startOfParagraph":false},{"content":"At this point, this object Bob has a name equal to Bob.","startTime":1104000,"duration":6000,"startOfParagraph":false},{"content":"Okay, down here I'm using that NSMutableArray that we looked at earlier.","startTime":1110000,"duration":5000,"startOfParagraph":false},{"content":"I'm allocating space.Then I'm initializing a new array.","startTime":1115000,"duration":3000,"startOfParagraph":false},{"content":"I'm going to add 2 things to it.","startTime":1118000,"duration":2000,"startOfParagraph":false},{"content":"This array now holds student objects.","startTime":1120000,"duration":3000,"startOfParagraph":false},{"content":"Notice that nowhere did I have to say this is an array of students.","startTime":1123000,"duration":3000,"startOfParagraph":false},{"content":"I said it's an array, period.","startTime":1126000,"duration":2000,"startOfParagraph":false},{"content":"Then I can put whatever inside of it that I want.","startTime":1128000,"duration":2000,"startOfParagraph":false},{"content":"Here I have 2 objects.","startTime":1130000,"duration":2000,"startOfParagraph":false},{"content":"Finally, I have another object here, this TF.","startTime":1132000,"duration":4000,"startOfParagraph":true},{"content":"Over here in TF.h basically the same thing.","startTime":1136000,"duration":3000,"startOfParagraph":false},{"content":"I'm inheriting from NSObject, and by the way, ","startTime":1139000,"duration":2000,"startOfParagraph":false},{"content":"when you create classes this is all done for you,","startTime":1141000,"duration":2000,"startOfParagraph":false},{"content":"this kind of interface boilerplate.","startTime":1143000,"duration":3000,"startOfParagraph":false},{"content":"It has a property of students. ","startTime":1146000,"duration":2000,"startOfParagraph":false},{"content":"I have a couple methods here that don't really do a whole lot,","startTime":1148000,"duration":7000,"startOfParagraph":false},{"content":"and so that means after I create this TF object","startTime":1155000,"duration":3000,"startOfParagraph":false},{"content":"I can call this method grade on it like this.","startTime":1158000,"duration":5000,"startOfParagraph":false},{"content":"Any questions on Objective-C syntax before we start moving into some more ","startTime":1163000,"duration":3000,"startOfParagraph":false},{"content":"interesting apps development stuff?","startTime":1166000,"duration":4000,"startOfParagraph":false},{"content":"Okay, so let's actually make an iPhone app.","startTime":1170000,"duration":4000,"startOfParagraph":true},{"content":"The core classes that you'll be using inside of your iPhone app are called view controllers,","startTime":1174000,"duration":5000,"startOfParagraph":false},{"content":"and a view controller basically represents a single screen","startTime":1179000,"duration":3000,"startOfParagraph":false},{"content":"inside of your app, so if I'm on the music app, for example,","startTime":1182000,"duration":4000,"startOfParagraph":false},{"content":"one view controller could represent the view in which I view all the songs on my iPhone.","startTime":1186000,"duration":4000,"startOfParagraph":false},{"content":"Another view controller could be when I click a song and start playing it","startTime":1190000,"duration":3000,"startOfParagraph":false},{"content":"or as I'm drilling down into artists.","startTime":1193000,"duration":2000,"startOfParagraph":false},{"content":"Each of those different screens could be represented as a different view controller,","startTime":1195000,"duration":4000,"startOfParagraph":false},{"content":"and a view controller is really just a class that says how this screen works.","startTime":1199000,"duration":5000,"startOfParagraph":false},{"content":"Things inside of a view controller, we're going to have properties,","startTime":1204000,"duration":3000,"startOfParagraph":false},{"content":"so things like a button is going to be a property of our view controller.","startTime":1207000,"duration":3000,"startOfParagraph":false},{"content":"We're also going to have methods, and these are basically event handlers.","startTime":1210000,"duration":3000,"startOfParagraph":true},{"content":"This method says when you press this button ","startTime":1213000,"duration":3000,"startOfParagraph":false},{"content":"I want to do something, and finally, again, ","startTime":1216000,"duration":3000,"startOfParagraph":false},{"content":"we're going to be using this self keyword to access the current instance.","startTime":1219000,"duration":5000,"startOfParagraph":false},{"content":"To build interfaces in iOS is actually really, really easy.","startTime":1224000,"duration":5000,"startOfParagraph":false},{"content":"They have this nice drag and drop interface called Interface Builder,","startTime":1229000,"duration":3000,"startOfParagraph":false},{"content":"and the 2 core concepts that wire up your Objective-C to Interface Builder","startTime":1232000,"duration":5000,"startOfParagraph":false},{"content":"are IBOutlet and IBAction.","startTime":1237000,"duration":3000,"startOfParagraph":false},{"content":"An IBOutlet simply says that if you declare a property that's a button,","startTime":1240000,"duration":4000,"startOfParagraph":false},{"content":"and you want to hook it up to something in your actual UI,","startTime":1244000,"duration":3000,"startOfParagraph":false},{"content":"you're going to say it's an outlet.","startTime":1247000,"duration":2000,"startOfParagraph":false},{"content":"Similarly, if you want to represent an event handler ","startTime":1249000,"duration":2000,"startOfParagraph":false},{"content":"then you're going to say it's an action.","startTime":1251000,"duration":3000,"startOfParagraph":false},{"content":"To actually wire up this graphical representation","startTime":1254000,"duration":3000,"startOfParagraph":true},{"content":"and your code it's really, really simple.","startTime":1257000,"duration":3000,"startOfParagraph":false},{"content":"If you want to attach an IBOutlet, all you have to do is you control click,","startTime":1260000,"duration":3000,"startOfParagraph":false},{"content":"and we'll see an example of this really quick.","startTime":1263000,"duration":2000,"startOfParagraph":false},{"content":"You control click where it says View Controller.","startTime":1265000,"duration":2000,"startOfParagraph":false},{"content":"You're going to drag into the interface, or conversely,","startTime":1267000,"duration":2000,"startOfParagraph":false},{"content":"if you want to hook up an event handler you're going to drag from the interface","startTime":1269000,"duration":4000,"startOfParagraph":false},{"content":"in the other direction.","startTime":1273000,"duration":2000,"startOfParagraph":false},{"content":"Let's take a look at a really simple iOS example.","startTime":1275000,"duration":5000,"startOfParagraph":false},{"content":"Let's create a new project.","startTime":1280000,"duration":3000,"startOfParagraph":true},{"content":"I'm going to come up here to Application,","startTime":1283000,"duration":2000,"startOfParagraph":false},{"content":"and I'm going to click Single View Application.","startTime":1285000,"duration":3000,"startOfParagraph":false},{"content":"I'm going to click next. I'll give my project a name.","startTime":1288000,"duration":3000,"startOfParagraph":false},{"content":"I'll call it Hello.","startTime":1291000,"duration":2000,"startOfParagraph":false},{"content":"Interestingly, Apple assumes you're creating a product","startTime":1293000,"duration":3000,"startOfParagraph":false},{"content":"so that you can sell it and they can make money.","startTime":1296000,"duration":2000,"startOfParagraph":false},{"content":"Down here I'm going to say that this is an iPhone app.","startTime":1298000,"duration":3000,"startOfParagraph":false},{"content":"You can create an iPad app, or if you want to create one of those apps","startTime":1301000,"duration":3000,"startOfParagraph":false},{"content":"that supports both devices you can do that too.","startTime":1304000,"duration":3000,"startOfParagraph":false},{"content":"These are what you want your checkmarks to look like.","startTime":1307000,"duration":2000,"startOfParagraph":false},{"content":"You want to use storyboards, which we'll see later,","startTime":1309000,"duration":2000,"startOfParagraph":true},{"content":"and you definitely want to use automatic reference counting,","startTime":1311000,"duration":3000,"startOfParagraph":false},{"content":"which is a nice feature that prevents you from having to say malloc and free.","startTime":1314000,"duration":4000,"startOfParagraph":false},{"content":"Unless you want to call malloc and free, I would leave this checked.","startTime":1318000,"duration":5000,"startOfParagraph":false},{"content":"I'll click next, and finally, this is going to ask me where I want to save it.","startTime":1323000,"duration":4000,"startOfParagraph":false},{"content":"I'll hit create, and here we go.","startTime":1327000,"duration":7000,"startOfParagraph":false},{"content":"I created a new project.","startTime":1334000,"duration":2000,"startOfParagraph":false},{"content":"Over here on the left are all the files that are inside of my project,","startTime":1336000,"duration":3000,"startOfParagraph":false},{"content":"and notice that I got a whole bunch, and I didn't even do anything.","startTime":1339000,"duration":3000,"startOfParagraph":false},{"content":"IOS is great.","startTime":1342000,"duration":2000,"startOfParagraph":false},{"content":"For example, here this ViewController.h, ","startTime":1344000,"duration":3000,"startOfParagraph":true},{"content":"this is going to represent my first view controller,","startTime":1347000,"duration":3000,"startOfParagraph":false},{"content":"so the first screen inside of my app.","startTime":1350000,"duration":2000,"startOfParagraph":false},{"content":"Now we know what this is saying. ","startTime":1352000,"duration":2000,"startOfParagraph":false},{"content":"We're saying I'm calling this class ViewController,","startTime":1354000,"duration":2000,"startOfParagraph":false},{"content":"and a ViewController does everything that a UIViewController does,","startTime":1356000,"duration":4000,"startOfParagraph":false},{"content":"and this, again, is some class that Apple wrote that does a lot of handy stuff for us","startTime":1360000,"duration":3000,"startOfParagraph":false},{"content":"like display the screen.","startTime":1363000,"duration":3000,"startOfParagraph":false},{"content":"Here is where I can actually start defining what my view controller does,","startTime":1366000,"duration":4000,"startOfParagraph":false},{"content":"and it turns out that I really don't need any of this.","startTime":1370000,"duration":2000,"startOfParagraph":false},{"content":"This is boilerplate code that Apple gives me for free.","startTime":1372000,"duration":3000,"startOfParagraph":false},{"content":"I did need that first line, or I don't have a class,","startTime":1375000,"duration":4000,"startOfParagraph":false},{"content":"so we can get rid of that and get rid of this.","startTime":1379000,"duration":3000,"startOfParagraph":false},{"content":"Okay, so this is my empty screen.","startTime":1382000,"duration":3000,"startOfParagraph":false},{"content":"Now let's click on this MainStoryboard.storyboard,","startTime":1385000,"duration":3000,"startOfParagraph":true},{"content":"and this is where it starts to get interesting.","startTime":1388000,"duration":3000,"startOfParagraph":false},{"content":"This represents the first screen on my app.","startTime":1391000,"duration":3000,"startOfParagraph":false},{"content":"If I want to add a button, in HTML I had to create a button tag.","startTime":1394000,"duration":3000,"startOfParagraph":false},{"content":"In Android you have to create a button tag,","startTime":1397000,"duration":3000,"startOfParagraph":false},{"content":"but in iOS if I just come down here to the bottom right","startTime":1400000,"duration":3000,"startOfParagraph":false},{"content":"and if I click on this 3rd one here where it says Objects,","startTime":1403000,"duration":4000,"startOfParagraph":false},{"content":"and I can scroll down, or I can start searching for button.","startTime":1407000,"duration":4000,"startOfParagraph":false},{"content":"And look, a button, so if I actually drag and drop this right there,","startTime":1411000,"duration":4000,"startOfParagraph":false},{"content":"I've just added a button to this screen on my app.","startTime":1415000,"duration":3000,"startOfParagraph":false},{"content":"If I want to change the text, I can double click it,","startTime":1418000,"duration":3000,"startOfParagraph":false},{"content":"say something enticing like \"Press Me.\"","startTime":1421000,"duration":6000,"startOfParagraph":false},{"content":"Okay, now if I run this app, so we compile it, ","startTime":1427000,"duration":4000,"startOfParagraph":false},{"content":"so to run it I click the play button in the top left, and there's my app.","startTime":1431000,"duration":3000,"startOfParagraph":false},{"content":"I didn't do anything, and I got a sweet looking iPhone app.","startTime":1434000,"duration":4000,"startOfParagraph":false},{"content":"If I want to stop it, you can click the stop button","startTime":1438000,"duration":3000,"startOfParagraph":false},{"content":"because it's more fun.","startTime":1441000,"duration":2000,"startOfParagraph":false},{"content":"Let's say that I actually want something to happen when I press this button.","startTime":1443000,"duration":4000,"startOfParagraph":true},{"content":"To do that what I need to do is I need to create","startTime":1447000,"duration":2000,"startOfParagraph":false},{"content":"a new event handler or an action.","startTime":1449000,"duration":4000,"startOfParagraph":false},{"content":"That means that I need to create some method that I want to be called","startTime":1453000,"duration":3000,"startOfParagraph":false},{"content":"when I press the button, so let's create a new method.","startTime":1456000,"duration":2000,"startOfParagraph":false},{"content":"I'm inside of ViewController.h.","startTime":1458000,"duration":2000,"startOfParagraph":false},{"content":"I need to say that a method exists. ","startTime":1460000,"duration":2000,"startOfParagraph":false},{"content":"I need a hyphen first because I'm going to be calling this on the view controller.","startTime":1462000,"duration":4000,"startOfParagraph":false},{"content":"I need to give this a type.","startTime":1466000,"duration":2000,"startOfParagraph":false},{"content":"The type of this is going to be that IBAction thing that we saw earlier.","startTime":1468000,"duration":3000,"startOfParagraph":false},{"content":"This is an event handler, so it's going to return an IBAction,","startTime":1471000,"duration":4000,"startOfParagraph":false},{"content":"and this is a hint to XCode to say that","startTime":1475000,"duration":3000,"startOfParagraph":false},{"content":"this is something I want to wire something to.","startTime":1478000,"duration":2000,"startOfParagraph":false},{"content":"I can give it a name, like buttonPressed, semicolon.","startTime":1480000,"duration":5000,"startOfParagraph":false},{"content":"Now I've declared a new method inside of my class.","startTime":1485000,"duration":3000,"startOfParagraph":true},{"content":"I've said this method has to exist.","startTime":1488000,"duration":2000,"startOfParagraph":false},{"content":"Now let's come into ViewController.m,","startTime":1490000,"duration":3000,"startOfParagraph":false},{"content":"and let's say what this method can do.","startTime":1493000,"duration":3000,"startOfParagraph":false},{"content":"If I start typing, for example, (void)buttonPressed","startTime":1496000,"duration":7000,"startOfParagraph":false},{"content":"notice XCode is really nice and autocompletes for me.","startTime":1503000,"duration":3000,"startOfParagraph":false},{"content":"That's really wonderful.","startTime":1506000,"duration":3000,"startOfParagraph":false},{"content":"Notice here that inside of the .m file I can also say void,","startTime":1509000,"duration":3000,"startOfParagraph":false},{"content":"and this is because that IBAction isn't actually a type.","startTime":1512000,"duration":3000,"startOfParagraph":false},{"content":"It's actually hashtag defined somewhere to be a void,","startTime":1515000,"duration":4000,"startOfParagraph":false},{"content":"and again, this is just a hint to XCode that says","startTime":1519000,"duration":3000,"startOfParagraph":false},{"content":"I want this to be an event handler, and we'll see why in just a second.","startTime":1522000,"duration":3000,"startOfParagraph":false},{"content":"When this button is pressed I'm going to do something annoying","startTime":1525000,"duration":3000,"startOfParagraph":false},{"content":"like display a popup.","startTime":1528000,"duration":2000,"startOfParagraph":false},{"content":"To do that I can create a new instance of this class called UIAlertView,","startTime":1530000,"duration":5000,"startOfParagraph":true},{"content":"and this is a class that Apple wrote that's going to display annoying popups.","startTime":1535000,"duration":4000,"startOfParagraph":false},{"content":"We'll call this popup alert, and I have 2 steps, remember, to creating this object.","startTime":1539000,"duration":4000,"startOfParagraph":false},{"content":"The first thing I need to do is allocate space.","startTime":1543000,"duration":3000,"startOfParagraph":false},{"content":"I want a UIAlertView.","startTime":1546000,"duration":2000,"startOfParagraph":false},{"content":"I want to allocate space. That's my first method.","startTime":1548000,"duration":3000,"startOfParagraph":false},{"content":"My next method is I want to initialize it,","startTime":1551000,"duration":2000,"startOfParagraph":false},{"content":"and so I have this big, long method called initWithTitle.","startTime":1553000,"duration":5000,"startOfParagraph":false},{"content":"That's basically going to control what this popup says.","startTime":1558000,"duration":3000,"startOfParagraph":false},{"content":"The title of my popup can be hello.","startTime":1561000,"duration":3000,"startOfParagraph":false},{"content":"The message of this popup can be \"This is iOS.\" ","startTime":1564000,"duration":4000,"startOfParagraph":false},{"content":"Delegate thing, I don't know what that is.","startTime":1568000,"duration":2000,"startOfParagraph":false},{"content":"Let's say it's nothing.","startTime":1570000,"duration":3000,"startOfParagraph":false},{"content":"Now the button that's going to appear can say something like \"It sure is,\"","startTime":1573000,"duration":5000,"startOfParagraph":false},{"content":"and I don't really want any other buttons, so let's delete that and close the bracket.","startTime":1578000,"duration":6000,"startOfParagraph":false},{"content":"Okay, I created an extra one. There we go.","startTime":1584000,"duration":3000,"startOfParagraph":true},{"content":"This is how I can create a new popup.","startTime":1587000,"duration":3000,"startOfParagraph":false},{"content":"If I want to actually show the popup I want to call the show method.","startTime":1590000,"duration":5000,"startOfParagraph":false},{"content":"To do that I can say alert and show,","startTime":1595000,"duration":3000,"startOfParagraph":false},{"content":"and again, autocomplete was super nice.","startTime":1598000,"duration":2000,"startOfParagraph":false},{"content":"If I forgot what that was, if I just typed in s,","startTime":1600000,"duration":2000,"startOfParagraph":false},{"content":"I can scroll through here to figure out what it was, ","startTime":1602000,"duration":3000,"startOfParagraph":false},{"content":"and it filters nicely.","startTime":1605000,"duration":3000,"startOfParagraph":false},{"content":"Now I created this new popup.","startTime":1608000,"duration":4000,"startOfParagraph":false},{"content":"We'll come back to what delegate means later,","startTime":1612000,"duration":3000,"startOfParagraph":false},{"content":"and now I want to say I want this method to be fired","startTime":1615000,"duration":3000,"startOfParagraph":false},{"content":"when I press the button, so I'm going to come back to my storyboard,","startTime":1618000,"duration":3000,"startOfParagraph":false},{"content":"and I want to now attach this IBAction.","startTime":1621000,"duration":3000,"startOfParagraph":false},{"content":"The first thing you want to do is click the button.","startTime":1624000,"duration":2000,"startOfParagraph":false},{"content":"When I press this button I want something to happen.","startTime":1626000,"duration":2000,"startOfParagraph":false},{"content":"I'm not going to hold down control.","startTime":1628000,"duration":2000,"startOfParagraph":false},{"content":"I'm going to click and drag from the button ","startTime":1630000,"duration":3000,"startOfParagraph":false},{"content":"to over here where it says View Controller.","startTime":1633000,"duration":2000,"startOfParagraph":false},{"content":"We can see that it nicely lights up.","startTime":1635000,"duration":2000,"startOfParagraph":false},{"content":"If I let go with my mouse I now have this popup over here where I have some options.","startTime":1637000,"duration":5000,"startOfParagraph":true},{"content":"One of these is the events that I can register.","startTime":1642000,"duration":2000,"startOfParagraph":false},{"content":"These are all of those methods I declared in my h file as IBActions.","startTime":1644000,"duration":4000,"startOfParagraph":false},{"content":"This is how XCode knows what should appear in this little list,","startTime":1648000,"duration":3000,"startOfParagraph":false},{"content":"so that's just a hint.","startTime":1651000,"duration":2000,"startOfParagraph":false},{"content":"If I click on button pressed, I've now registered the event handler.","startTime":1653000,"duration":4000,"startOfParagraph":false},{"content":"In JavaScript we had to say I have some code that registered the event handler.","startTime":1657000,"duration":4000,"startOfParagraph":false},{"content":"In Objective-C it was really that easy.","startTime":1661000,"duration":2000,"startOfParagraph":false},{"content":"If I run this again ","startTime":1663000,"duration":3000,"startOfParagraph":false},{"content":"now when I press the button my event handler is going to fire,","startTime":1666000,"duration":3000,"startOfParagraph":false},{"content":"and I'm going to get this popup.","startTime":1669000,"duration":2000,"startOfParagraph":false},{"content":"Super, super simple there.","startTime":1671000,"duration":3000,"startOfParagraph":false},{"content":"If you ever want to see all of the events that happen to be registered","startTime":1674000,"duration":3000,"startOfParagraph":true},{"content":"on a component if I click on this button","startTime":1677000,"duration":3000,"startOfParagraph":false},{"content":"and I come over here to the right side","startTime":1680000,"duration":2000,"startOfParagraph":false},{"content":"first you can see over here I can do things like the type of the button,","startTime":1682000,"duration":3000,"startOfParagraph":false},{"content":"so if you want one of those I's or the add contact button","startTime":1685000,"duration":3000,"startOfParagraph":false},{"content":"or whatever.","startTime":1688000,"duration":2000,"startOfParagraph":false},{"content":"If I want to see all of the events that are on this button","startTime":1690000,"duration":3000,"startOfParagraph":false},{"content":"if I come all the way over here to the right side","startTime":1693000,"duration":3000,"startOfParagraph":false},{"content":"we can see here at the events I have all of these different events.","startTime":1696000,"duration":3000,"startOfParagraph":false},{"content":"I can press the button, when I let go of the button, when I double tap or whatever,","startTime":1699000,"duration":4000,"startOfParagraph":false},{"content":"and the one I just registered is this event called Touch Up Inside,","startTime":1703000,"duration":3000,"startOfParagraph":false},{"content":"and this says that as soon as my finger comes off the button","startTime":1706000,"duration":3000,"startOfParagraph":false},{"content":"that event is going to fire, and that's exactly what just happened.","startTime":1709000,"duration":3000,"startOfParagraph":false},{"content":"This is kind of the default button pressed event.","startTime":1712000,"duration":4000,"startOfParagraph":false},{"content":"Any questions so far?","startTime":1716000,"duration":3000,"startOfParagraph":true},{"content":"Okay, that's how we can start to wire up things in our code","startTime":1719000,"duration":4000,"startOfParagraph":false},{"content":"into things inside of our interface.","startTime":1723000,"duration":3000,"startOfParagraph":false},{"content":"Remember the first thing we had to do was to find the code,","startTime":1726000,"duration":3000,"startOfParagraph":false},{"content":"and then we wired up the interface to the code,","startTime":1729000,"duration":5000,"startOfParagraph":false},{"content":"and there's our first app.","startTime":1734000,"duration":3000,"startOfParagraph":false},{"content":"Okay, that was really cool, and we created this button.","startTime":1737000,"duration":3000,"startOfParagraph":false},{"content":"What if we don't want to have to create a bunch of properties","startTime":1740000,"duration":3000,"startOfParagraph":false},{"content":"representing these buttons?","startTime":1743000,"duration":2000,"startOfParagraph":false},{"content":"For example, in Tic Tac Toe I have 9 buttons,","startTime":1745000,"duration":3000,"startOfParagraph":false},{"content":"and it'd be super, super annoying to have to drag and drop 9 times","startTime":1748000,"duration":3000,"startOfParagraph":false},{"content":"or if I had to make Tic Tac Toe with 81 instead of 9","startTime":1751000,"duration":3000,"startOfParagraph":false},{"content":"and I had to drag and drop 81 times, and that's lame.","startTime":1754000,"duration":3000,"startOfParagraph":false},{"content":"What we can do instead is much like an HTML","startTime":1757000,"duration":3000,"startOfParagraph":false},{"content":"when we had things like IDs and names and we can search for things","startTime":1760000,"duration":3000,"startOfParagraph":false},{"content":"by their ID, there's a similar notion in iOS called tags.","startTime":1763000,"duration":4000,"startOfParagraph":false},{"content":"A tag is simply a unique numerical identifier for a component.","startTime":1767000,"duration":4000,"startOfParagraph":true},{"content":"If I say this has a tag of 0, for example,","startTime":1771000,"duration":3000,"startOfParagraph":false},{"content":"if I create a button and give it a tag of 0, and we'll see how to do that in just a second,","startTime":1774000,"duration":4000,"startOfParagraph":false},{"content":"if I want to get that button I can simply say I want to call","startTime":1778000,"duration":3000,"startOfParagraph":false},{"content":"the viewWithTag method on the object over here,","startTime":1781000,"duration":4000,"startOfParagraph":false},{"content":"the self.view, which represents the current screen, for example.","startTime":1785000,"duration":3000,"startOfParagraph":false},{"content":"If I call that viewWithTag method, I'm going to pull back the button with tag 0.","startTime":1788000,"duration":5000,"startOfParagraph":false},{"content":"Let's take a look at this by building Tic Tac Toe.","startTime":1793000,"duration":5000,"startOfParagraph":false},{"content":"First, this is my storyboard.","startTime":1798000,"duration":3000,"startOfParagraph":false},{"content":"I've created these 10 UI buttons.","startTime":1801000,"duration":4000,"startOfParagraph":false},{"content":"Notice they're all the same size.","startTime":1805000,"duration":2000,"startOfParagraph":false},{"content":"If I click one of these and I come back over here on this right side","startTime":1807000,"duration":4000,"startOfParagraph":false},{"content":"you'll see I adjusted the font right here, so I made the font a little bit bigger,","startTime":1811000,"duration":4000,"startOfParagraph":false},{"content":"but what I also did was I set this tag.","startTime":1815000,"duration":4000,"startOfParagraph":false},{"content":"I said that this has a tag of 1, and that's the top left.","startTime":1819000,"duration":4000,"startOfParagraph":false},{"content":"Now, if I click another button, like this second one here,","startTime":1823000,"duration":3000,"startOfParagraph":true},{"content":"now you'll see that my tag is 2.","startTime":1826000,"duration":3000,"startOfParagraph":false},{"content":"Each of these buttons just has a unique tag,","startTime":1829000,"duration":3000,"startOfParagraph":false},{"content":"and so this is later how I'm going to start interacting","startTime":1832000,"duration":3000,"startOfParagraph":false},{"content":"with my app.","startTime":1835000,"duration":3000,"startOfParagraph":false},{"content":"This is all inside of one view controller,","startTime":1838000,"duration":2000,"startOfParagraph":false},{"content":"but here is what we have.","startTime":1840000,"duration":2000,"startOfParagraph":false},{"content":"We have 3 properties here.","startTime":1842000,"duration":2000,"startOfParagraph":false},{"content":"The first one and last one are going to represent the state of my board.","startTime":1844000,"duration":5000,"startOfParagraph":false},{"content":"Basically this first one is an array representing where the Xs and Os are.","startTime":1849000,"duration":4000,"startOfParagraph":false},{"content":"This other one here tells us whose turn it is.","startTime":1853000,"duration":4000,"startOfParagraph":false},{"content":"You'll notice that I also have these things here.","startTime":1857000,"duration":4000,"startOfParagraph":false},{"content":"Before when we declared properties we gave them a name and a type.","startTime":1861000,"duration":4000,"startOfParagraph":false},{"content":"We can also give them some additional information here.","startTime":1865000,"duration":3000,"startOfParagraph":false},{"content":"This first says nonatomic, and what this says ","startTime":1868000,"duration":3000,"startOfParagraph":false},{"content":"is basically only one thing will ever be trying to access this variable at a time.","startTime":1871000,"duration":5000,"startOfParagraph":false},{"content":"You could do more complex applications that are multi-threaded,","startTime":1876000,"duration":3000,"startOfParagraph":false},{"content":"and so back in Scratch we had different threads,","startTime":1879000,"duration":3000,"startOfParagraph":false},{"content":"and different sprites could be doing different things at the same time.","startTime":1882000,"duration":3000,"startOfParagraph":false},{"content":"If that's not the case, which it is not in anything that we'll be looking at,","startTime":1885000,"duration":4000,"startOfParagraph":true},{"content":"if we say nonatomic it's actually going to make things a little bit faster.","startTime":1889000,"duration":4000,"startOfParagraph":false},{"content":"We also have this thing called assign, strong, or weak.","startTime":1893000,"duration":4000,"startOfParagraph":false},{"content":"This assign just says that this is a standard type. ","startTime":1897000,"duration":3000,"startOfParagraph":false},{"content":"This is not an object or a pointer because this is just a bool,","startTime":1900000,"duration":3000,"startOfParagraph":false},{"content":"so bool is built into Objective-C.","startTime":1903000,"duration":3000,"startOfParagraph":false},{"content":"This says don't try to do anything fancy with pointers here.","startTime":1906000,"duration":3000,"startOfParagraph":false},{"content":"It's a regular old scaler.","startTime":1909000,"duration":2000,"startOfParagraph":false},{"content":"Strong and weak, this weak says that actually ","startTime":1911000,"duration":3000,"startOfParagraph":false},{"content":"I want this to be pointing to something in the view controller.","startTime":1914000,"duration":3000,"startOfParagraph":false},{"content":"I'm not going to actually allocate or init this myself.","startTime":1917000,"duration":3000,"startOfParagraph":false},{"content":"The interface builder, when I run the app, is going to handle all that initialization.","startTime":1920000,"duration":4000,"startOfParagraph":false},{"content":"If I say weak, that says someone else is going to be creating this.","startTime":1924000,"duration":3000,"startOfParagraph":false},{"content":"If I say strong, this says that I'm going to be the one ","startTime":1927000,"duration":2000,"startOfParagraph":false},{"content":"that's creating this board object,","startTime":1929000,"duration":3000,"startOfParagraph":false},{"content":"and so here I have some more methods here,","startTime":1932000,"duration":2000,"startOfParagraph":false},{"content":"for example, an action for when the new game button is pressed,","startTime":1934000,"duration":4000,"startOfParagraph":false},{"content":"an action for when any of the other buttons are pressed,","startTime":1938000,"duration":2000,"startOfParagraph":false},{"content":"and et cetera. ","startTime":1940000,"duration":3000,"startOfParagraph":false},{"content":"We won't get into too much of the logic of Tic Tac Toe,","startTime":1943000,"duration":3000,"startOfParagraph":true},{"content":"although it's very exciting, but let's take a look at","startTime":1946000,"duration":4000,"startOfParagraph":false},{"content":"some of the things that we can do inside of iOS.","startTime":1950000,"duration":3000,"startOfParagraph":false},{"content":"This new game method is going to be fired ","startTime":1953000,"duration":2000,"startOfParagraph":false},{"content":"whenever I press the new game button.","startTime":1955000,"duration":2000,"startOfParagraph":false},{"content":"To hook that up I simply come over to my storyboard.","startTime":1957000,"duration":4000,"startOfParagraph":false},{"content":"I clicked on new game.","startTime":1961000,"duration":2000,"startOfParagraph":false},{"content":"If I come over here to the right I can see that","startTime":1963000,"duration":4000,"startOfParagraph":false},{"content":"Touch Up Inside is wired to the newGame method.","startTime":1967000,"duration":3000,"startOfParagraph":false},{"content":"That's why this is going to get fired.","startTime":1970000,"duration":3000,"startOfParagraph":false},{"content":"The newGame method is going to do some set up.","startTime":1973000,"duration":3000,"startOfParagraph":false},{"content":"It's going to say I want you to clear the state of the board.","startTime":1976000,"duration":3000,"startOfParagraph":false},{"content":"This is a nice method on mutable arrays.","startTime":1979000,"duration":2000,"startOfParagraph":false},{"content":"This is going to say it's now X's turn,","startTime":1981000,"duration":2000,"startOfParagraph":false},{"content":"and now I'm going to take advantage of this viewWithTag thing.","startTime":1983000,"duration":4000,"startOfParagraph":false},{"content":"I know that my buttons have the tags 1-9,","startTime":1987000,"duration":4000,"startOfParagraph":true},{"content":"and that's something I arbitrarily picked.","startTime":1991000,"duration":2000,"startOfParagraph":false},{"content":"If I want to set the text of each button to be empty","startTime":1993000,"duration":2000,"startOfParagraph":false},{"content":"because I just started a new game and I don't want any ","startTime":1995000,"duration":2000,"startOfParagraph":false},{"content":"Xs or Os to be left over I can do this.","startTime":1997000,"duration":3000,"startOfParagraph":false},{"content":"I can say I want the view with the tag, 1, 2, 3, 4 et cetera.","startTime":2000000,"duration":4000,"startOfParagraph":false},{"content":"This will pull a different button each time.","startTime":2004000,"duration":3000,"startOfParagraph":false},{"content":"Here I'm going to cast it to UIButton.","startTime":2007000,"duration":3000,"startOfParagraph":false},{"content":"Just like we could cast ints to floats and vice versa","startTime":2010000,"duration":3000,"startOfParagraph":false},{"content":"this says that I want to cast this to a UIButton.","startTime":2013000,"duration":4000,"startOfParagraph":false},{"content":"That means the type of this will be a UIButton*","startTime":2017000,"duration":3000,"startOfParagraph":false},{"content":"because of pointers, but don't worry, they're not scary anymore.","startTime":2020000,"duration":3000,"startOfParagraph":false},{"content":"Once I have this button I'm going to call a method on it.","startTime":2023000,"duration":4000,"startOfParagraph":true},{"content":"This method is called setTitle forState, and so this says","startTime":2027000,"duration":3000,"startOfParagraph":false},{"content":"I want to set the text of the button to be the empty string,","startTime":2030000,"duration":3000,"startOfParagraph":false},{"content":"and I want it to be the empty string when it's not pressed.","startTime":2033000,"duration":4000,"startOfParagraph":false},{"content":"If I'm using this method, I can change the text of the button","startTime":2037000,"duration":4000,"startOfParagraph":false},{"content":"as soon as someone hits it, but we want to say when the button is just sitting there","startTime":2041000,"duration":3000,"startOfParagraph":false},{"content":"I want the text to be blank.","startTime":2044000,"duration":3000,"startOfParagraph":false},{"content":"Finally, we're going to initialize my board,","startTime":2047000,"duration":3000,"startOfParagraph":false},{"content":"and I'm going to say that everything is currently at 0,","startTime":2050000,"duration":2000,"startOfParagraph":false},{"content":"so this board members immutable is a mutable array,","startTime":2052000,"duration":3000,"startOfParagraph":false},{"content":"which means I can call the addObject method and just a 0 inside of it.","startTime":2055000,"duration":6000,"startOfParagraph":false},{"content":"That's what happens when I create a new game.","startTime":2061000,"duration":2000,"startOfParagraph":false},{"content":"Let's take a look at another one.","startTime":2063000,"duration":2000,"startOfParagraph":true},{"content":"This method here is the IBAction that's going to be pressed","startTime":2065000,"duration":3000,"startOfParagraph":false},{"content":"every time one of those squares is pressed.","startTime":2068000,"duration":3000,"startOfParagraph":false},{"content":"Now we have some Tic Tac Toe logic here.","startTime":2071000,"duration":2000,"startOfParagraph":false},{"content":"We figure out whose turn it is,","startTime":2073000,"duration":3000,"startOfParagraph":false},{"content":"and based on that we either set an X or an O,","startTime":2076000,"duration":3000,"startOfParagraph":false},{"content":"but we notice that we're reusing this same event handler ","startTime":2079000,"duration":4000,"startOfParagraph":false},{"content":"for every single one of those buttons.","startTime":2083000,"duration":2000,"startOfParagraph":false},{"content":"That means that I don't have a method for the top left button,","startTime":2085000,"duration":4000,"startOfParagraph":false},{"content":"a different method for the bottom right button, although I could have done that.","startTime":2089000,"duration":3000,"startOfParagraph":false},{"content":"That wouldn't really be good design.","startTime":2092000,"duration":2000,"startOfParagraph":false},{"content":"What I'm doing here is I'm actually going to determine","startTime":2094000,"duration":3000,"startOfParagraph":false},{"content":"what the tag of the button that was pressed is.","startTime":2097000,"duration":3000,"startOfParagraph":false},{"content":"You notice that this play method takes one argument.","startTime":2100000,"duration":4000,"startOfParagraph":false},{"content":"It's called sender, and what sender is is sender is going to","startTime":2104000,"duration":3000,"startOfParagraph":false},{"content":"represent exactly what was taken action upon.","startTime":2107000,"duration":3000,"startOfParagraph":false},{"content":"If I press a button, this sender is going to be that UIButton","startTime":2110000,"duration":5000,"startOfParagraph":false},{"content":"that I actually pressed, so that means that that UIButton","startTime":2115000,"duration":3000,"startOfParagraph":false},{"content":"has a tag because I created a tag.","startTime":2118000,"duration":2000,"startOfParagraph":false},{"content":"If I want to get at the tag I can simply say","startTime":2120000,"duration":3000,"startOfParagraph":true},{"content":"I want the tag of the sender, ","startTime":2123000,"duration":3000,"startOfParagraph":false},{"content":"and again, I've just casted it to a UIButton.","startTime":2126000,"duration":2000,"startOfParagraph":false},{"content":"I happen to know that the sender will be a UIButton.","startTime":2128000,"duration":4000,"startOfParagraph":false},{"content":"It doesn't always have to be a UIButton.","startTime":2132000,"duration":2000,"startOfParagraph":false},{"content":"I could, for example, register the same event handler","startTime":2134000,"duration":2000,"startOfParagraph":false},{"content":" for one for a button, one for a slider.","startTime":2136000,"duration":2000,"startOfParagraph":false},{"content":"In this case, I know they're all buttons, so I'm going to say ","startTime":2138000,"duration":2000,"startOfParagraph":false},{"content":"I want this to be a button, and then I can get the tag,","startTime":2140000,"duration":3000,"startOfParagraph":false},{"content":"and from the tag I now know where I am inside of the board.","startTime":2143000,"duration":5000,"startOfParagraph":false},{"content":"Then I can simply set either the X or the O, can flip the turn,","startTime":2148000,"duration":3000,"startOfParagraph":false},{"content":"check who has won, et cetera.","startTime":2151000,"duration":3000,"startOfParagraph":false},{"content":"Any questions on this so far?","startTime":2154000,"duration":5000,"startOfParagraph":true},{"content":"Okay, all the code we posted online—we don't want to get into too much ","startTime":2159000,"duration":3000,"startOfParagraph":false},{"content":"of the Tic Tac Toe logic, but now you can see that really ","startTime":2162000,"duration":4000,"startOfParagraph":false},{"content":"all we're doing is we're looping over this array,","startTime":2166000,"duration":3000,"startOfParagraph":false},{"content":"so we have a couple of for loops here, and we're just comparing to see","startTime":2169000,"duration":4000,"startOfParagraph":false},{"content":"do we have a match in all the rows, a match in a column or anything like that.","startTime":2173000,"duration":5000,"startOfParagraph":false},{"content":"To actually run this app, if I tap on one of these buttons","startTime":2178000,"duration":3000,"startOfParagraph":false},{"content":"that play method was fired, so that means I just set","startTime":2181000,"duration":3000,"startOfParagraph":false},{"content":"the button to be an X, so now this button will be an O, and so on,","startTime":2184000,"duration":7000,"startOfParagraph":false},{"content":"and so that's how we're starting to interact with this single page app.","startTime":2191000,"duration":4000,"startOfParagraph":false},{"content":"We'll post the code, so feel free to peruse that,","startTime":2195000,"duration":3000,"startOfParagraph":true},{"content":"but let's now talk about some apps that are more than just one page.","startTime":2198000,"duration":5000,"startOfParagraph":false},{"content":"As exciting as Tic Tac Toe was, a lot of apps inside of iOS ","startTime":2203000,"duration":4000,"startOfParagraph":false},{"content":"are kind of these drill down things with multiple screens.","startTime":2207000,"duration":3000,"startOfParagraph":false},{"content":"The first concept that we'll need to talk about are protocols,","startTime":2210000,"duration":4000,"startOfParagraph":false},{"content":"and a protocol is simply a set of methods","startTime":2214000,"duration":3000,"startOfParagraph":false},{"content":"that you can promise to define.","startTime":2217000,"duration":2000,"startOfParagraph":false},{"content":"If I create this new protocol with 2 methods, this first one, ","startTime":2219000,"duration":3000,"startOfParagraph":false},{"content":"if the return type is void, I called it foo. ","startTime":2222000,"duration":3000,"startOfParagraph":false},{"content":"It takes no arguments. I have another method. ","startTime":2225000,"duration":2000,"startOfParagraph":false},{"content":"It returns an int. I called it bar, and it takes one argument.","startTime":2227000,"duration":4000,"startOfParagraph":false},{"content":"All this protocol is that's called SomeProtocol up here,","startTime":2231000,"duration":3000,"startOfParagraph":false},{"content":"this is a set of things that someone can implement.","startTime":2234000,"duration":5000,"startOfParagraph":false},{"content":"I haven't inside of this protocol said what foo does.","startTime":2239000,"duration":3000,"startOfParagraph":false},{"content":"Instead, I'm just saying you could define foo if you want to.","startTime":2242000,"duration":4000,"startOfParagraph":false},{"content":"If I'm creating a view controller or creating a class","startTime":2246000,"duration":4000,"startOfParagraph":false},{"content":"I can inside of that class promise to implement","startTime":2250000,"duration":3000,"startOfParagraph":false},{"content":"some of these methods, so for example, if say ","startTime":2253000,"duration":7000,"startOfParagraph":false},{"content":"this now says I'm making a promise to you that inside ","startTime":2260000,"duration":3000,"startOfParagraph":false},{"content":"of this view controller class I will have definitions for both foo and bar.","startTime":2263000,"duration":7000,"startOfParagraph":false},{"content":"Why is that useful?","startTime":2270000,"duration":2000,"startOfParagraph":true},{"content":"A lot of components inside of iOS take advantage of this ","startTime":2272000,"duration":3000,"startOfParagraph":false},{"content":"design pattern called delegation, and what delegation says","startTime":2275000,"duration":3000,"startOfParagraph":false},{"content":"is that, for example, if I have a text box","startTime":2278000,"duration":3000,"startOfParagraph":false},{"content":"and there are some events that could be registered inside of my text box,","startTime":2281000,"duration":3000,"startOfParagraph":false},{"content":"rather than creating separate events what I can do is I can say","startTime":2284000,"duration":3000,"startOfParagraph":false},{"content":"the delegate of this text box will be some object.","startTime":2287000,"duration":3000,"startOfParagraph":false},{"content":"When I say that this is a delegate now that means that","startTime":2290000,"duration":3000,"startOfParagraph":false},{"content":"whenever some event would have been fired in the text box","startTime":2293000,"duration":3000,"startOfParagraph":false},{"content":"rather than having to register it or anything like that","startTime":2296000,"duration":2000,"startOfParagraph":false},{"content":"it's just going to call a method on the delegate.","startTime":2298000,"duration":3000,"startOfParagraph":false},{"content":"For example, inside of my text box I have a method for when I press","startTime":2301000,"duration":3000,"startOfParagraph":false},{"content":"that done button in the bottom right,","startTime":2304000,"duration":3000,"startOfParagraph":false},{"content":"and so rather than registering event handler what I can say is","startTime":2307000,"duration":3000,"startOfParagraph":false},{"content":"text box, here is an object that I want you to call a method on","startTime":2310000,"duration":4000,"startOfParagraph":false},{"content":"every time someone presses the done button,","startTime":2314000,"duration":3000,"startOfParagraph":false},{"content":"and that means that that object has to implement some protocol","startTime":2317000,"duration":3000,"startOfParagraph":false},{"content":"that says I promise to define that done button action,","startTime":2320000,"duration":5000,"startOfParagraph":false},{"content":"because if it doesn't define that method and you press done, ","startTime":2325000,"duration":2000,"startOfParagraph":false},{"content":"then it's going to be confusing.","startTime":2327000,"duration":2000,"startOfParagraph":false},{"content":"Let's take a look at an example.","startTime":2329000,"duration":6000,"startOfParagraph":true},{"content":"Here I simply have one text box,","startTime":2335000,"duration":3000,"startOfParagraph":false},{"content":"and one of the properties of this text box over here on this right side is the delegate.","startTime":2338000,"duration":6000,"startOfParagraph":false},{"content":"This is a property of the class.","startTime":2344000,"duration":2000,"startOfParagraph":false},{"content":"What I did here is I control clicked, and I dragged from this spot over here","startTime":2346000,"duration":3000,"startOfParagraph":false},{"content":"to the view controller, and that says now the delegate of this text box","startTime":2349000,"duration":4000,"startOfParagraph":false},{"content":"is going to be the view controller.","startTime":2353000,"duration":5000,"startOfParagraph":false},{"content":"That means that when some actions happen, rather than registering ","startTime":2358000,"duration":2000,"startOfParagraph":false},{"content":"separate event handlers I want you to send them to the delegate.","startTime":2360000,"duration":5000,"startOfParagraph":false},{"content":"Now let's take a look at my view controller.","startTime":2365000,"duration":3000,"startOfParagraph":false},{"content":"Inside of the .h file I've made a promise.","startTime":2368000,"duration":4000,"startOfParagraph":false},{"content":"I've promised to implement some methods inside of this protocol","startTime":2372000,"duration":4000,"startOfParagraph":false},{"content":"called UITextFieldDelegate, and again,","startTime":2376000,"duration":2000,"startOfParagraph":false},{"content":"this is just some list of some things that I can choose to implement.","startTime":2378000,"duration":4000,"startOfParagraph":false},{"content":"If I come here in my .m file, I have implemented one such method.","startTime":2382000,"duration":4000,"startOfParagraph":true},{"content":"I've called it textFieldShouldReturn","startTime":2386000,"duration":3000,"startOfParagraph":false},{"content":"because that's what it was called inside of the protocol.","startTime":2389000,"duration":3000,"startOfParagraph":false},{"content":"And now whenever I press the done button inside of that text field","startTime":2392000,"duration":5000,"startOfParagraph":false},{"content":"this is what's going to get called, so I did not register an event handler.","startTime":2397000,"duration":3000,"startOfParagraph":false},{"content":"I connected the delegate, and whenever this event is fired","startTime":2400000,"duration":3000,"startOfParagraph":false},{"content":"this is the method that will get called, so if I come over here to my storyboard and run it—","startTime":2403000,"duration":5000,"startOfParagraph":false},{"content":"while that's loading we can see what this does.","startTime":2408000,"duration":3000,"startOfParagraph":false},{"content":"On my screen I have 2 things.","startTime":2411000,"duration":2000,"startOfParagraph":false},{"content":"I have this text field, and I have this label.","startTime":2413000,"duration":3000,"startOfParagraph":false},{"content":"I'm simply saying I want the text of this label","startTime":2416000,"duration":3000,"startOfParagraph":false},{"content":"to be equal to whatever the user typed in inside of the text field.","startTime":2419000,"duration":4000,"startOfParagraph":false},{"content":"This next line here is simply a method that I'm calling","startTime":2423000,"duration":3000,"startOfParagraph":false},{"content":"on the text field that says I want you to hide the keyboard.","startTime":2426000,"duration":3000,"startOfParagraph":false},{"content":"This is just the arbitrary method that Apple chose.","startTime":2429000,"duration":4000,"startOfParagraph":false},{"content":"Again, before I did anything I had to wire everything up, so I first came over here.","startTime":2433000,"duration":5000,"startOfParagraph":true},{"content":"From the view controller I drag over to the text box.","startTime":2438000,"duration":4000,"startOfParagraph":false},{"content":"I let go, and I can see here that I can make this the text field property","startTime":2442000,"duration":4000,"startOfParagraph":false},{"content":"since over here in the view controller I've defined a property","startTime":2446000,"duration":3000,"startOfParagraph":false},{"content":"that is an IBOutlet of a text field.","startTime":2449000,"duration":3000,"startOfParagraph":false},{"content":"This says that I can wire this property up","startTime":2452000,"duration":3000,"startOfParagraph":false},{"content":"to a text field in my UI.","startTime":2455000,"duration":4000,"startOfParagraph":false},{"content":"Now when I click this I can start typing.","startTime":2459000,"duration":4000,"startOfParagraph":false},{"content":"Now if I click the done button this is going to fire","startTime":2463000,"duration":3000,"startOfParagraph":false},{"content":"an event that I can now respond to.","startTime":2466000,"duration":2000,"startOfParagraph":false},{"content":"No event handlers. ","startTime":2468000,"duration":2000,"startOfParagraph":false},{"content":"That's how I just responded to that done button.","startTime":2470000,"duration":3000,"startOfParagraph":false},{"content":"Make sense?","startTime":2473000,"duration":2000,"startOfParagraph":false},{"content":"This isn't a design pattern that—you might not ever find yourself","startTime":2475000,"duration":5000,"startOfParagraph":true},{"content":"creating your own protocol, but just know that some","startTime":2480000,"duration":3000,"startOfParagraph":false},{"content":"different iOS components register events in different ways.","startTime":2483000,"duration":4000,"startOfParagraph":false},{"content":"Buttons, for example, use those IBActions.","startTime":2487000,"duration":2000,"startOfParagraph":false},{"content":"Text fields, on the other hand, are going to use delegates.","startTime":2489000,"duration":3000,"startOfParagraph":false},{"content":"We can see and you can look all of that up inside of the documentation.","startTime":2492000,"duration":4000,"startOfParagraph":false},{"content":"By the way, there's actually a ton of UI stuff built into iOS for you,","startTime":2496000,"duration":5000,"startOfParagraph":false},{"content":"so for example, the way I made that say done at the bottom right","startTime":2501000,"duration":5000,"startOfParagraph":false},{"content":"is I selected this text field.","startTime":2506000,"duration":2000,"startOfParagraph":false},{"content":"I came over here. ","startTime":2508000,"duration":2000,"startOfParagraph":false},{"content":"I scrolled down a bit to return key,","startTime":2510000,"duration":3000,"startOfParagraph":false},{"content":"and I can actually make this a whole bunch of things, like if I want that to say","startTime":2513000,"duration":3000,"startOfParagraph":false},{"content":"emergency call instead I can do that, which is totally random,","startTime":2516000,"duration":4000,"startOfParagraph":false},{"content":"and I don't know why there's a built-in emergency call button,","startTime":2520000,"duration":2000,"startOfParagraph":false},{"content":"but there, it says emergency call in really small letters.","startTime":2522000,"duration":4000,"startOfParagraph":false},{"content":"There you go.","startTime":2526000,"duration":2000,"startOfParagraph":false},{"content":"Definitely explore all of these different options in iOS.","startTime":2528000,"duration":4000,"startOfParagraph":true},{"content":"Any questions on delegates?","startTime":2532000,"duration":2000,"startOfParagraph":false},{"content":"Again, just an interesting design pattern that you should be aware of.","startTime":2534000,"duration":4000,"startOfParagraph":false},{"content":"Okay, let's next take a look at table views.","startTime":2538000,"duration":4000,"startOfParagraph":false},{"content":"A table view is basically that list of items that is all over the place in iOS.","startTime":2542000,"duration":4000,"startOfParagraph":false},{"content":"When you're flipping through all of your contacts, you're looking at ","startTime":2546000,"duration":3000,"startOfParagraph":false},{"content":"the setting page, and that kind of list of things is called a table view.","startTime":2549000,"duration":5000,"startOfParagraph":false},{"content":"Implementing a table view in iOS is pretty simple.","startTime":2554000,"duration":3000,"startOfParagraph":false},{"content":"Instead of making a class that descends from that UIViewController","startTime":2557000,"duration":4000,"startOfParagraph":false},{"content":"like we've done before we simply need to say rather than ","startTime":2561000,"duration":3000,"startOfParagraph":false},{"content":"everything a UIViewController does I want to do,","startTime":2564000,"duration":2000,"startOfParagraph":false},{"content":"I say everything a UITableViewController does I want to do,","startTime":2566000,"duration":4000,"startOfParagraph":false},{"content":"so that simply adds some additional things that are totally done for us.","startTime":2570000,"duration":4000,"startOfParagraph":false},{"content":"We need to do very little to basically fill in the blanks inside of the table.","startTime":2574000,"duration":4000,"startOfParagraph":false},{"content":"In order to display a table I need to answer some questions.","startTime":2578000,"duration":4000,"startOfParagraph":true},{"content":"The first question I need to answer is how many sections are in the table?","startTime":2582000,"duration":4000,"startOfParagraph":false},{"content":"When you're flipping through your contacts app you'll notice that it's kind of ","startTime":2586000,"duration":2000,"startOfParagraph":false},{"content":"organized by the As, then you have the Bs, and you have that little sub header.","startTime":2588000,"duration":4000,"startOfParagraph":false},{"content":"Each of those is called a section.","startTime":2592000,"duration":2000,"startOfParagraph":false},{"content":"You may or may not need these.","startTime":2594000,"duration":2000,"startOfParagraph":false},{"content":"The first thing you need to do is implement a method","startTime":2596000,"duration":3000,"startOfParagraph":false},{"content":"called tableView:numberOfSectionsInTableView.","startTime":2599000,"duration":3000,"startOfParagraph":false},{"content":"That simply returns how many sections you have,","startTime":2602000,"duration":3000,"startOfParagraph":false},{"content":"so this could say return one if you have one big table view.","startTime":2605000,"duration":4000,"startOfParagraph":false},{"content":"The next question that iOS needs to know is how many rows do you have?","startTime":2609000,"duration":4000,"startOfParagraph":false},{"content":"For example, you're flipping through a table view.","startTime":2613000,"duration":3000,"startOfParagraph":false},{"content":"You have a fixed number of songs you're looking at or a fixed number of contacts.","startTime":2616000,"duration":3000,"startOfParagraph":false},{"content":"If you're me, of course, not that many,","startTime":2619000,"duration":2000,"startOfParagraph":false},{"content":"and so that's how iOS knows how many cells to display.","startTime":2621000,"duration":3000,"startOfParagraph":false},{"content":"Again, this could say something like return 3.","startTime":2624000,"duration":2000,"startOfParagraph":true},{"content":"My table view has 3 rows.","startTime":2626000,"duration":3000,"startOfParagraph":false},{"content":"Finally, iOS needs to know what each cell looks like,","startTime":2629000,"duration":3000,"startOfParagraph":false},{"content":"so what it's actually going to do is call this method down here,","startTime":2632000,"duration":2000,"startOfParagraph":false},{"content":"this tableView:cellForRowAtIndexPath.","startTime":2634000,"duration":3000,"startOfParagraph":false},{"content":"It's going to call this method on every single cell inside of your table.","startTime":2637000,"duration":4000,"startOfParagraph":false},{"content":"How does it know how many times to call it?","startTime":2641000,"duration":2000,"startOfParagraph":false},{"content":"Well, you told it inside of number of rows in section.","startTime":2643000,"duration":3000,"startOfParagraph":false},{"content":"We're going to call this on each of our cells,","startTime":2646000,"duration":2000,"startOfParagraph":false},{"content":"and inside of this is where you can actually do things like ","startTime":2648000,"duration":3000,"startOfParagraph":false},{"content":"set the text or tell you what that little blue button on the right side does.","startTime":2651000,"duration":5000,"startOfParagraph":false},{"content":"The pattern for getting these cells, we're going to use this method","startTime":2656000,"duration":3000,"startOfParagraph":false},{"content":"called dequeueReusableCellWithIdentifier.","startTime":2659000,"duration":3000,"startOfParagraph":false},{"content":"Objective-C is actually very well known for the ridiculous length of their method names,","startTime":2662000,"duration":7000,"startOfParagraph":true},{"content":"and this is really a nice case in point example.","startTime":2669000,"duration":3000,"startOfParagraph":false},{"content":"What this method does is this just says I want you to give me a cell.","startTime":2672000,"duration":5000,"startOfParagraph":false},{"content":"Just an iOS thing.","startTime":2677000,"duration":2000,"startOfParagraph":false},{"content":"If you have something like 100,000 songs on your iPod","startTime":2679000,"duration":2000,"startOfParagraph":false},{"content":"what iOS doesn't want to do is allocate 100,000 cells,","startTime":2681000,"duration":4000,"startOfParagraph":false},{"content":"because if you're at the top of your list, do you really need to allocate memory","startTime":2685000,"duration":3000,"startOfParagraph":false},{"content":"for the cell that's 99,000 rows down?","startTime":2688000,"duration":3000,"startOfParagraph":false},{"content":"No, because as you're scrolling you can kind of allocate as you go along.","startTime":2691000,"duration":4000,"startOfParagraph":false},{"content":"This is done for you. ","startTime":2695000,"duration":2000,"startOfParagraph":false},{"content":"You don't have to worry about all that stupid performance stuff. ","startTime":2697000,"duration":2000,"startOfParagraph":false},{"content":"All you say is you call this method dequeueReusableCellWithIdentifier,","startTime":2699000,"duration":3000,"startOfParagraph":false},{"content":"and this says, okay, if you need to I'm going to create a new cell for you.","startTime":2702000,"duration":4000,"startOfParagraph":false},{"content":"But if you're at the bottom of the table and you've already allocated some cells","startTime":2706000,"duration":3000,"startOfParagraph":true},{"content":"at the top of the table that you're really not going to need anytime soon","startTime":2709000,"duration":3000,"startOfParagraph":false},{"content":"I'm going to give you one of those back instead of allocating a new one,","startTime":2712000,"duration":3000,"startOfParagraph":false},{"content":"and so this is a nice performance concern.","startTime":2715000,"duration":2000,"startOfParagraph":false},{"content":"You do not have to allocate the cells yourself.","startTime":2717000,"duration":4000,"startOfParagraph":false},{"content":"That's going to give you back a cell.","startTime":2721000,"duration":2000,"startOfParagraph":false},{"content":"It's going to return to you a cell object.","startTime":2723000,"duration":2000,"startOfParagraph":false},{"content":"Once you have the cell object you can do stuff to it.","startTime":2725000,"duration":3000,"startOfParagraph":false},{"content":"You can set the text of the cell with this property called text label.","startTime":2728000,"duration":4000,"startOfParagraph":false},{"content":"You can add that arrow on the right or some other random stuff","startTime":2732000,"duration":4000,"startOfParagraph":false},{"content":"with this other property called accessoryType, and so on and so on.","startTime":2736000,"duration":5000,"startOfParagraph":false},{"content":"Let's take a look at actually implementing a table view now.","startTime":2741000,"duration":5000,"startOfParagraph":true},{"content":"When I created this project ","startTime":2746000,"duration":3000,"startOfParagraph":false},{"content":"rather than saying single view application I actually came over here","startTime":2749000,"duration":4000,"startOfParagraph":false},{"content":"to master-detail application, and so basically this corresponds to the mail app","startTime":2753000,"duration":4000,"startOfParagraph":false},{"content":"on the iPad with the table view on the left and then the contents on the right.","startTime":2757000,"duration":4000,"startOfParagraph":false},{"content":"On the iPod or iPhone this is going to correspond to a single table view.","startTime":2761000,"duration":6000,"startOfParagraph":false},{"content":"That's where I got my starter code. ","startTime":2767000,"duration":3000,"startOfParagraph":false},{"content":"Let's first take a look at the storyboard.","startTime":2770000,"duration":3000,"startOfParagraph":true},{"content":"All of this was done for me, basically created.","startTime":2773000,"duration":2000,"startOfParagraph":false},{"content":"This navigation bar showed me what an example cell could look like,","startTime":2775000,"duration":3000,"startOfParagraph":false},{"content":"and I can double click this, change the title.","startTime":2778000,"duration":4000,"startOfParagraph":false},{"content":"Any other UI concerns I can handle there.","startTime":2782000,"duration":3000,"startOfParagraph":false},{"content":"The header file looks really simple.","startTime":2785000,"duration":2000,"startOfParagraph":false},{"content":"Rather than saying this is UIViewController we're now saying this is a ","startTime":2787000,"duration":3000,"startOfParagraph":false},{"content":"TableViewController, so we know that we want to call all those table methods.","startTime":2790000,"duration":5000,"startOfParagraph":false},{"content":"Next I want to create a property that's going to represent","startTime":2795000,"duration":3000,"startOfParagraph":false},{"content":"the things inside of my table.","startTime":2798000,"duration":2000,"startOfParagraph":false},{"content":"This table is going to arbitrarily display","startTime":2800000,"duration":3000,"startOfParagraph":false},{"content":"a list of fruit, and so I need to create some array","startTime":2803000,"duration":3000,"startOfParagraph":false},{"content":"in which I can insert fruit.","startTime":2806000,"duration":3000,"startOfParagraph":false},{"content":"Inside of my implementation file the first thing I want to do ","startTime":2809000,"duration":3000,"startOfParagraph":false},{"content":"is I want to make sure I initialize this array.","startTime":2812000,"duration":3000,"startOfParagraph":false},{"content":"I said alloc init, created my fruit array,","startTime":2815000,"duration":3000,"startOfParagraph":true},{"content":"and I'm adding 4 things to it, one of which is much more controversial than the other 3.","startTime":2818000,"duration":5000,"startOfParagraph":false},{"content":"And now I have an array of size 4.","startTime":2823000,"duration":3000,"startOfParagraph":false},{"content":"We're shaking it up in CS50.","startTime":2826000,"duration":2000,"startOfParagraph":false},{"content":"I now have an array of size 4.","startTime":2828000,"duration":3000,"startOfParagraph":false},{"content":"Now I'm going to start answering these questions, and actually,","startTime":2831000,"duration":2000,"startOfParagraph":false},{"content":"when I created this app all of this was already done for me.","startTime":2833000,"duration":3000,"startOfParagraph":false},{"content":"I didn't have to type out the number of sections in table view.","startTime":2836000,"duration":3000,"startOfParagraph":false},{"content":"It was already there, and I'm filling in the blanks.","startTime":2839000,"duration":3000,"startOfParagraph":false},{"content":"How many sections do I have? ","startTime":2842000,"duration":2000,"startOfParagraph":false},{"content":"One. All done.","startTime":2844000,"duration":2000,"startOfParagraph":false},{"content":"How many rows do I have?","startTime":2846000,"duration":2000,"startOfParagraph":false},{"content":"Well, I have one row for every fruit, so this count ","startTime":2848000,"duration":3000,"startOfParagraph":false},{"content":"is a property of any array that says how big is it?","startTime":2851000,"duration":3000,"startOfParagraph":false},{"content":"That's how many rows I have.","startTime":2854000,"duration":2000,"startOfParagraph":false},{"content":"Finally, I need to say what does each cell look like?","startTime":2856000,"duration":6000,"startOfParagraph":false},{"content":"I'm going to say dequeueReusableCellWithIdentifier.","startTime":2862000,"duration":4000,"startOfParagraph":false},{"content":"Again, this was already written for me. ","startTime":2866000,"duration":2000,"startOfParagraph":true},{"content":"I didn't have to do this myself, and I want to get back ","startTime":2868000,"duration":3000,"startOfParagraph":false},{"content":"this cell at this location.","startTime":2871000,"duration":3000,"startOfParagraph":false},{"content":"Remember that we're calling this same method on every single cell,","startTime":2874000,"duration":3000,"startOfParagraph":false},{"content":"and this argument here, this indexPath argument,","startTime":2877000,"duration":4000,"startOfParagraph":false},{"content":"says what row I'm in.","startTime":2881000,"duration":2000,"startOfParagraph":false},{"content":"If I say indexPath.row down here","startTime":2883000,"duration":2000,"startOfParagraph":false},{"content":"this will be 0, then it will be 1, then it will be 2, and this is so I know","startTime":2885000,"duration":4000,"startOfParagraph":false},{"content":"what cell I'm currently displaying.","startTime":2889000,"duration":2000,"startOfParagraph":false},{"content":"I want to set the text of the cell using this textLabel property","startTime":2891000,"duration":4000,"startOfParagraph":false},{"content":"to go inside my fruit array and get ","startTime":2895000,"duration":4000,"startOfParagraph":false},{"content":"the object corresponding to each row.","startTime":2899000,"duration":2000,"startOfParagraph":false},{"content":"If this is a string, I'm now setting","startTime":2901000,"duration":3000,"startOfParagraph":false},{"content":"the text property to a string.","startTime":2904000,"duration":4000,"startOfParagraph":false},{"content":"I can do one other thing.","startTime":2908000,"duration":2000,"startOfParagraph":false},{"content":"I can also register an event handler on each of the cells,","startTime":2910000,"duration":2000,"startOfParagraph":false},{"content":"so when I tap each of these cells ","startTime":2912000,"duration":3000,"startOfParagraph":false},{"content":"this didSelectRowAtIndexPath, this is going to be called for me,","startTime":2915000,"duration":4000,"startOfParagraph":false},{"content":"so simply by defining this I can now handle what happens","startTime":2919000,"duration":3000,"startOfParagraph":false},{"content":"when you tap a cell, and again, we're passing in which cell was tapped","startTime":2922000,"duration":4000,"startOfParagraph":false},{"content":"so that we can reuse this same event handler for all of our cells.","startTime":2926000,"duration":4000,"startOfParagraph":false},{"content":"Again, this is something iOS is doing for me.","startTime":2930000,"duration":3000,"startOfParagraph":true},{"content":"Let's display another annoying popup","startTime":2933000,"duration":2000,"startOfParagraph":false},{"content":"that simply says you picked something where that something ","startTime":2935000,"duration":4000,"startOfParagraph":false},{"content":"is going to be the row object.","startTime":2939000,"duration":5000,"startOfParagraph":false},{"content":"When I run this, I'm going to have this nice table view","startTime":2944000,"duration":6000,"startOfParagraph":false},{"content":"with one row for each of these fruit, and if I tap one","startTime":2950000,"duration":4000,"startOfParagraph":false},{"content":"it tells me what happened.","startTime":2954000,"duration":2000,"startOfParagraph":false},{"content":"Make sense?","startTime":2956000,"duration":5000,"startOfParagraph":false},{"content":"Let's build a little bit more complex of an app,","startTime":2961000,"duration":3000,"startOfParagraph":false},{"content":"as much as clicking you picked tomato is.","startTime":2964000,"duration":4000,"startOfParagraph":false},{"content":"The nice part about the storyboarding ","startTime":2968000,"duration":3000,"startOfParagraph":false},{"content":"is it's not only going to help us design screens individually,","startTime":2971000,"duration":4000,"startOfParagraph":false},{"content":"it's also going to help us tie together our entire app,","startTime":2975000,"duration":3000,"startOfParagraph":false},{"content":"so the final app we'll be building is this nice sports news reader,","startTime":2978000,"duration":4000,"startOfParagraph":false},{"content":"and so it's going to have multiple screens, and so I can actually represent","startTime":2982000,"duration":3000,"startOfParagraph":false},{"content":"each of these multiple screens on the storyboard,","startTime":2985000,"duration":3000,"startOfParagraph":false},{"content":"and I can zoom out and see my app from a high level.","startTime":2988000,"duration":4000,"startOfParagraph":false},{"content":"In order to create a new element inside of my storyboard","startTime":2992000,"duration":3000,"startOfParagraph":true},{"content":"it's really simple inside of Interface Builder.","startTime":2995000,"duration":4000,"startOfParagraph":false},{"content":"If I want to add another screen to this, for example,","startTime":2999000,"duration":2000,"startOfParagraph":false},{"content":"I can first zoom out with the pinch zoom that Apple loves so much,","startTime":3001000,"duration":5000,"startOfParagraph":false},{"content":"and down here before I search for a button","startTime":3006000,"duration":3000,"startOfParagraph":false},{"content":"and I drag and drop a button","startTime":3009000,"duration":3000,"startOfParagraph":false},{"content":"if I want to create a new screen I can actually just drag and drop","startTime":3012000,"duration":3000,"startOfParagraph":false},{"content":"an entire view controller, so if I pick this, pull it over here,","startTime":3015000,"duration":4000,"startOfParagraph":false},{"content":"hey, there's another screen, and so now using this same storyboard file","startTime":3019000,"duration":4000,"startOfParagraph":false},{"content":"I can have all of the screens inside of my app, and I can zoom out ","startTime":3023000,"duration":3000,"startOfParagraph":false},{"content":"and see how they interact.","startTime":3026000,"duration":2000,"startOfParagraph":false},{"content":"These won't interact yet.","startTime":3028000,"duration":4000,"startOfParagraph":false},{"content":"The way in which these 2 screens interact is you define relationships.","startTime":3032000,"duration":4000,"startOfParagraph":false},{"content":"You can basically say this screen, when you press this button,","startTime":3036000,"duration":3000,"startOfParagraph":false},{"content":"I want you to slide over to this new screen.","startTime":3039000,"duration":3000,"startOfParagraph":false},{"content":"That means there's this kind of relationship between","startTime":3042000,"duration":2000,"startOfParagraph":false},{"content":" the first screen and the second screen.","startTime":3044000,"duration":2000,"startOfParagraph":false},{"content":"You'll have basically an arrow from that button to the second screen","startTime":3046000,"duration":3000,"startOfParagraph":false},{"content":"saying that when you press this button that's where I want to go.","startTime":3049000,"duration":4000,"startOfParagraph":false},{"content":"Just like we control clicked and dragged to define those outlets","startTime":3053000,"duration":4000,"startOfParagraph":false},{"content":"we're going to do the same thing to define these segues.","startTime":3057000,"duration":4000,"startOfParagraph":false},{"content":"We'll see an example for that, and before we actually transition","startTime":3061000,"duration":4000,"startOfParagraph":true},{"content":"from one screen to another iOS is nice enough to call this method","startTime":3065000,"duration":3000,"startOfParagraph":false},{"content":"called prepareForSegue, and this is where we can start","startTime":3068000,"duration":3000,"startOfParagraph":false},{"content":"sending data from one app to another.","startTime":3071000,"duration":3000,"startOfParagraph":false},{"content":"In the example we're about to look at it will basically allow us ","startTime":3074000,"duration":3000,"startOfParagraph":false},{"content":"to filter baseball teams by leagues and divisions.","startTime":3077000,"duration":3000,"startOfParagraph":false},{"content":"When I select a league, for example, I want to transition","startTime":3080000,"duration":3000,"startOfParagraph":false},{"content":"to my next screen where I can display all of the divisions ","startTime":3083000,"duration":2000,"startOfParagraph":false},{"content":"in that league or all the different teams.","startTime":3085000,"duration":2000,"startOfParagraph":false},{"content":"I need to send to that screen what teams you should display.","startTime":3087000,"duration":4000,"startOfParagraph":false},{"content":"To do that I'm going to take advantage of this method here.","startTime":3091000,"duration":4000,"startOfParagraph":false},{"content":"Finally, just a random point on iOS.","startTime":3095000,"duration":4000,"startOfParagraph":true},{"content":"If you want to store data there's this thing called core data, ","startTime":3099000,"duration":2000,"startOfParagraph":false},{"content":"which is actually kind of complicated to work with.","startTime":3101000,"duration":3000,"startOfParagraph":false},{"content":"You can also use SQL to store data, ","startTime":3104000,"duration":3000,"startOfParagraph":false},{"content":"which, again, is nice but kind of on the more complicated side to work with,","startTime":3107000,"duration":4000,"startOfParagraph":false},{"content":"but iOS also supports these really cool things called property lists,","startTime":3111000,"duration":4000,"startOfParagraph":false},{"content":"and a property list is just a file that represents key value pairs.","startTime":3115000,"duration":5000,"startOfParagraph":false},{"content":"You define a list of keys, and you say this key is going to be an array.","startTime":3120000,"duration":3000,"startOfParagraph":false},{"content":"This key is going to be a string, and basically anything you can do ","startTime":3123000,"duration":3000,"startOfParagraph":false},{"content":"in JSON you can do inside of a property list, ","startTime":3126000,"duration":4000,"startOfParagraph":false},{"content":"and so this really nicely allows us to work with some data.","startTime":3130000,"duration":4000,"startOfParagraph":false},{"content":"For example, I have this Teams.plist that I created.","startTime":3134000,"duration":4000,"startOfParagraph":false},{"content":"I created a new plist file, and I can drill down.","startTime":3138000,"duration":4000,"startOfParagraph":false},{"content":"This is a dictionary, this is a dictionary, these are strings,","startTime":3142000,"duration":4000,"startOfParagraph":false},{"content":"and so this is a nice graphical representation of a JSON document","startTime":3146000,"duration":4000,"startOfParagraph":false},{"content":"or just a set of key value pairs,","startTime":3150000,"duration":3000,"startOfParagraph":false},{"content":"and so this is the data that I'll be working with inside of my app.","startTime":3153000,"duration":4000,"startOfParagraph":false},{"content":"Let's first come over here. We have a lot more files now.","startTime":3157000,"duration":3000,"startOfParagraph":true},{"content":"But let's first come over here to the storyboard.","startTime":3160000,"duration":4000,"startOfParagraph":false},{"content":"The storyboard here—if I can zoom out—","startTime":3164000,"duration":4000,"startOfParagraph":false},{"content":"we can now see that this is the flow of my app.","startTime":3168000,"duration":3000,"startOfParagraph":false},{"content":"I'm first going to start on this screen.","startTime":3171000,"duration":2000,"startOfParagraph":false},{"content":"I'm going to drill down to this screen,","startTime":3173000,"duration":2000,"startOfParagraph":false},{"content":"and I'm going to drill down to this screen, and we can see here that if I kind of ","startTime":3175000,"duration":3000,"startOfParagraph":false},{"content":"move one of these around we have these arrows going from here to here,","startTime":3178000,"duration":6000,"startOfParagraph":false},{"content":"and the way I define that arrow was if I zoom in a little bit,","startTime":3184000,"duration":4000,"startOfParagraph":false},{"content":"and if I come over to this view controller,","startTime":3188000,"duration":4000,"startOfParagraph":false},{"content":"and here's a cell, and I want to say that when you tap a cell","startTime":3192000,"duration":4000,"startOfParagraph":false},{"content":"I want you to slide over to another screen.","startTime":3196000,"duration":2000,"startOfParagraph":false},{"content":"I can simply hold down control,","startTime":3198000,"duration":3000,"startOfParagraph":false},{"content":"scroll over a little bit, hold down control, drag this cell over and let go.","startTime":3201000,"duration":5000,"startOfParagraph":false},{"content":"And over here we say what's the transition that you want to use?","startTime":3206000,"duration":4000,"startOfParagraph":true},{"content":"Do you want to use that slide thing that's called push?","startTime":3210000,"duration":2000,"startOfParagraph":false},{"content":"Do you want to slide up from the bottom?","startTime":3212000,"duration":2000,"startOfParagraph":false},{"content":"That's called modal.","startTime":3214000,"duration":2000,"startOfParagraph":false},{"content":"And once I click one of these, it's going to draw this arrow for me,","startTime":3216000,"duration":4000,"startOfParagraph":false},{"content":"and that means that I've actually handled what happens when I press this button graphically.","startTime":3220000,"duration":4000,"startOfParagraph":false},{"content":"I didn't write any code to actually slide from one screen to the next one.","startTime":3224000,"duration":4000,"startOfParagraph":false},{"content":"I defined this visually inside of Interface Builder.","startTime":3228000,"duration":3000,"startOfParagraph":false},{"content":"If I click on this arrow, we can see that I gave this thing a name.","startTime":3231000,"duration":4000,"startOfParagraph":false},{"content":"I called it showDivisions, and this is so that I can know","startTime":3235000,"duration":4000,"startOfParagraph":false},{"content":"what transition is about to occur, and we'll see why in just a sec.","startTime":3239000,"duration":4000,"startOfParagraph":false},{"content":"That's how I've wired up the different screens in my app.","startTime":3243000,"duration":3000,"startOfParagraph":false},{"content":"If this were a button, for example, rather than a table view,","startTime":3246000,"duration":3000,"startOfParagraph":false},{"content":"I could control click on the button, drag over to the next screen,","startTime":3249000,"duration":2000,"startOfParagraph":false},{"content":"and that's how I can do navigation that way.","startTime":3251000,"duration":5000,"startOfParagraph":false},{"content":"Really quickly, if we come into the MasterViewController,","startTime":3256000,"duration":3000,"startOfParagraph":true},{"content":"again, we're simply going to define a list of things ","startTime":3259000,"duration":3000,"startOfParagraph":false},{"content":"that will be displayed in the table view.","startTime":3262000,"duration":4000,"startOfParagraph":false},{"content":"Here I'm saying I want you to take that plist file,","startTime":3266000,"duration":3000,"startOfParagraph":false},{"content":"and I want you to load it up into a dictionary,","startTime":3269000,"duration":3000,"startOfParagraph":false},{"content":"and once you have that dictionary, I'm going to answer those same questions again.","startTime":3272000,"duration":3000,"startOfParagraph":false},{"content":"Here is the number of sections.","startTime":3275000,"duration":2000,"startOfParagraph":false},{"content":"One, there is one row for every league, and the text of each cell","startTime":3277000,"duration":4000,"startOfParagraph":false},{"content":"should be either the first one, the first league, the second league, and so on.","startTime":3281000,"duration":5000,"startOfParagraph":false},{"content":"Finally, I'm going to use this method that we just saw called prepareForSegue,","startTime":3286000,"duration":5000,"startOfParagraph":false},{"content":"and this is the method that's going to be fired when I click ","startTime":3291000,"duration":3000,"startOfParagraph":false},{"content":"on one of those rows and therefore activating that transition","startTime":3294000,"duration":3000,"startOfParagraph":false},{"content":"that I set up with the arrows.","startTime":3297000,"duration":2000,"startOfParagraph":false},{"content":"This is saying that I can have multiple ","startTime":3299000,"duration":3000,"startOfParagraph":false},{"content":"relationships from one screen to another. ","startTime":3302000,"duration":3000,"startOfParagraph":false},{"content":"If I have 2 buttons and each button takes you to a different screen","startTime":3305000,"duration":3000,"startOfParagraph":false},{"content":"I'm going to have 2 segues, 1 for each button.","startTime":3308000,"duration":2000,"startOfParagraph":false},{"content":"But this prepareForSegue is, again, going to be reused","startTime":3310000,"duration":4000,"startOfParagraph":false},{"content":"for each of the different relationships, so that means that I need a way","startTime":3314000,"duration":3000,"startOfParagraph":false},{"content":"of identifying if you press the first button or you press the second button.","startTime":3317000,"duration":4000,"startOfParagraph":false},{"content":"Remember when I gave that segue a name, this showDivisions,","startTime":3321000,"duration":4000,"startOfParagraph":true},{"content":"that's how I now know that this is the segue that was activated.","startTime":3325000,"duration":4000,"startOfParagraph":false},{"content":"All I want to do is I want to say ","startTime":3329000,"duration":3000,"startOfParagraph":false},{"content":"I want to figure out what I just hit,","startTime":3332000,"duration":3000,"startOfParagraph":false},{"content":"and so to get that, I can say I want the indexPath for the selected row,","startTime":3335000,"duration":3000,"startOfParagraph":false},{"content":"remember the indexPath just says where I just clicked,","startTime":3338000,"duration":4000,"startOfParagraph":false},{"content":"and then I want to say I want to figure out where I'm going.","startTime":3342000,"duration":5000,"startOfParagraph":false},{"content":"This destinationViewController, that's a property of the segue.","startTime":3347000,"duration":3000,"startOfParagraph":false},{"content":"That's the screen I'm going to,","startTime":3350000,"duration":3000,"startOfParagraph":false},{"content":"so I know that the screen I'm going to is called DivisionsViewController","startTime":3353000,"duration":3000,"startOfParagraph":false},{"content":"because I created that class,","startTime":3356000,"duration":3000,"startOfParagraph":false},{"content":"and so now if I say d.divisions","startTime":3359000,"duration":3000,"startOfParagraph":false},{"content":"I'm now setting a property of the view controller I'm about to go to.","startTime":3362000,"duration":4000,"startOfParagraph":false},{"content":"This is how I'm sending data from one screen to another screen.","startTime":3366000,"duration":4000,"startOfParagraph":false},{"content":"Just looking at this DivisionsViewController","startTime":3370000,"duration":3000,"startOfParagraph":true},{"content":"you can see here that in the .h file","startTime":3373000,"duration":3000,"startOfParagraph":false},{"content":"there is that property divisions, and that's what I'm basically populating,","startTime":3376000,"duration":4000,"startOfParagraph":false},{"content":"so that's how I know that I'm displaying the divisions corresponding to ","startTime":3380000,"duration":5000,"startOfParagraph":false},{"content":"the league that I clicked, and again,","startTime":3385000,"duration":3000,"startOfParagraph":false},{"content":"the actual table view looks pretty much the same, just answering those","startTime":3388000,"duration":3000,"startOfParagraph":false},{"content":"3 simple questions as well as identifying","startTime":3391000,"duration":3000,"startOfParagraph":false},{"content":"what happens when you move to the next screen.","startTime":3394000,"duration":3000,"startOfParagraph":false},{"content":"Just a couple of other things here.","startTime":3397000,"duration":3000,"startOfParagraph":false},{"content":"You notice at the top here that rather than saying #include","startTime":3400000,"duration":3000,"startOfParagraph":false},{"content":"I'm now saying #import.","startTime":3403000,"duration":2000,"startOfParagraph":false},{"content":"This is just an Objective-C thing.","startTime":3405000,"duration":2000,"startOfParagraph":false},{"content":"The import is basically a nicer version of include,","startTime":3407000,"duration":5000,"startOfParagraph":false},{"content":"and for example, we need to know what this class is,","startTime":3412000,"duration":5000,"startOfParagraph":false},{"content":"so I can't just say DivisionsViewController.","startTime":3417000,"duration":3000,"startOfParagraph":false},{"content":"If we didn't hashtag standardio.c inside of our .c file","startTime":3420000,"duration":5000,"startOfParagraph":false},{"content":"the compiler had no idea what printf was.","startTime":3425000,"duration":2000,"startOfParagraph":false},{"content":"Similarly, if I don't import the DivisionsViewController","startTime":3427000,"duration":5000,"startOfParagraph":false},{"content":"the compiler really has no idea what a DivisionsViewController is.","startTime":3432000,"duration":4000,"startOfParagraph":false},{"content":"Just make sure that inside of your different .m files you make sure to import","startTime":3436000,"duration":3000,"startOfParagraph":false},{"content":"the corresponding .h files so that the compiler knows what's going on.","startTime":3439000,"duration":6000,"startOfParagraph":false},{"content":"Finally, what Apple ultimately does is display some data using a web view,","startTime":3445000,"duration":6000,"startOfParagraph":true},{"content":"and so a web view is an object in which you can embed","startTime":3451000,"duration":4000,"startOfParagraph":false},{"content":"a little web browser inside of your app.","startTime":3455000,"duration":2000,"startOfParagraph":false},{"content":"All you need to do is supply a URL to your web browser,","startTime":3457000,"duration":3000,"startOfParagraph":false},{"content":"so I want to go to mlb.mlb.com,","startTime":3460000,"duration":3000,"startOfParagraph":false},{"content":"and this is how I can access the home page for each team,","startTime":3463000,"duration":3000,"startOfParagraph":false},{"content":"and so by passing in this URL","startTime":3466000,"duration":3000,"startOfParagraph":false},{"content":"the web view can display this for me, and I can browse around,","startTime":3469000,"duration":3000,"startOfParagraph":false},{"content":"and simulator is in use by that one.","startTime":3472000,"duration":9000,"startOfParagraph":false},{"content":"Now this came from my plist.","startTime":3481000,"duration":2000,"startOfParagraph":false},{"content":"If I click this this also came from my plist, and this sliding was handled","startTime":3483000,"duration":4000,"startOfParagraph":false},{"content":"by defining those segues.","startTime":3487000,"duration":2000,"startOfParagraph":false},{"content":"I click this and one more,","startTime":3489000,"duration":3000,"startOfParagraph":false},{"content":"and now here is my UIWebView, so just like that","startTime":3492000,"duration":3000,"startOfParagraph":false},{"content":"here's the website for the URL that I just embedded,","startTime":3495000,"duration":4000,"startOfParagraph":false},{"content":"and I didn't have to handle anything crazy.","startTime":3499000,"duration":2000,"startOfParagraph":false},{"content":"This is how to display a web page.","startTime":3501000,"duration":3000,"startOfParagraph":false},{"content":"Things like this back button here are also given to me","startTime":3504000,"duration":3000,"startOfParagraph":false},{"content":"totally for free because I've defined these relationships using segues.","startTime":3507000,"duration":6000,"startOfParagraph":false},{"content":"Any questions? Yeah.","startTime":3513000,"duration":4000,"startOfParagraph":true},{"content":"[Student] So when you use alloc, you never have to free anything?","startTime":3517000,"duration":3000,"startOfParagraph":false},{"content":"Exactly, when you call alloc and init you do not have to free it.","startTime":3520000,"duration":3000,"startOfParagraph":false},{"content":"IOS is going to handle all of that for you.","startTime":3523000,"duration":3000,"startOfParagraph":false},{"content":"It's wonderful, and you're not breaking any rules. Yeah.","startTime":3526000,"duration":5000,"startOfParagraph":false},{"content":"[Student] If you were to include more teams that could fit on the screen,","startTime":3531000,"duration":3000,"startOfParagraph":false},{"content":"would it automatically have a scroll option, or is that something you need to add?","startTime":3534000,"duration":4000,"startOfParagraph":false},{"content":"Exactly, if I had more teams, for example, it would automatically handle ","startTime":3538000,"duration":3000,"startOfParagraph":false},{"content":"the scrolling for me, and all the performance concerns","startTime":3541000,"duration":3000,"startOfParagraph":false},{"content":"with the huge table are also handled totally for me.","startTime":3544000,"duration":4000,"startOfParagraph":false},{"content":"Other questions?","startTime":3548000,"duration":3000,"startOfParagraph":true},{"content":"All of this code is going to be posted.","startTime":3551000,"duration":2000,"startOfParagraph":false},{"content":"We kind of glossed over a little bit of the more minor details,","startTime":3553000,"duration":3000,"startOfParagraph":false},{"content":"but things like setting some properties to the web view","startTime":3556000,"duration":3000,"startOfParagraph":false},{"content":"are just things that you can get by browsing Apple's documentation,","startTime":3559000,"duration":3000,"startOfParagraph":false},{"content":"which is really, really nicely laid out.","startTime":3562000,"duration":2000,"startOfParagraph":false},{"content":"They have a lot of sample apps and example usages ","startTime":3564000,"duration":3000,"startOfParagraph":false},{"content":"of different APIs, so definitely peruse those if you can.","startTime":3567000,"duration":7000,"startOfParagraph":false},{"content":"Just some helpful links you might want to take a look at.","startTime":3574000,"duration":2000,"startOfParagraph":false},{"content":"These are some handy documentation guides.","startTime":3576000,"duration":2000,"startOfParagraph":false},{"content":"The URLs are massive, so they're shortened.","startTime":3578000,"duration":3000,"startOfParagraph":false},{"content":"This first one is the entire library of documentation.","startTime":3581000,"duration":3000,"startOfParagraph":false},{"content":"There's little search bars, so if you start typing button","startTime":3584000,"duration":2000,"startOfParagraph":false},{"content":"it will start giving you all the information about all the things you can do with a button.","startTime":3586000,"duration":4000,"startOfParagraph":false},{"content":"I've also included the Table View Programming Guide.","startTime":3590000,"duration":3000,"startOfParagraph":false},{"content":"It handles table views in much more detail, ","startTime":3593000,"duration":3000,"startOfParagraph":false},{"content":"how to do things like dynamically add cells or edit cells or remove them.","startTime":3596000,"duration":4000,"startOfParagraph":false},{"content":"There's lots of sample apps from Apple that will show you how to do that,","startTime":3600000,"duration":2000,"startOfParagraph":true},{"content":"and finally, this last one is the Human Interface Guidelines,","startTime":3602000,"duration":3000,"startOfParagraph":false},{"content":"and this is basically some discussion of UI components,","startTime":3605000,"duration":4000,"startOfParagraph":false},{"content":"things like don't make a button that's 4 pixels by 4 pixels.","startTime":3609000,"duration":3000,"startOfParagraph":false},{"content":"That's a bad idea, and other things that Apple wants you to do","startTime":3612000,"duration":3000,"startOfParagraph":false},{"content":"to encourage good design.","startTime":3615000,"duration":3000,"startOfParagraph":false},{"content":"Any last questions before we finish up?","startTime":3618000,"duration":5000,"startOfParagraph":true},{"content":"All right, definitely feel free to—we're going to have special labels on Discuss.","startTime":3623000,"duration":4000,"startOfParagraph":false},{"content":"We'll have an iOS one, so definitely feel free to utilize that.","startTime":3627000,"duration":3000,"startOfParagraph":false},{"content":"If you want to work with your classmates on projects","startTime":3630000,"duration":4000,"startOfParagraph":false},{"content":"or help figure out some random iOS stuff","startTime":3634000,"duration":3000,"startOfParagraph":false},{"content":"feel free to email me, and definitely peruse all the code online because ","startTime":3637000,"duration":3000,"startOfParagraph":false},{"content":"just in the interest of time we kind of glossed over the more ","startTime":3640000,"duration":3000,"startOfParagraph":false},{"content":"finer grained details of things.","startTime":3643000,"duration":2000,"startOfParagraph":false},{"content":"But if not, then good luck on your iOS projects, and I hope we have","startTime":3645000,"duration":2000,"startOfParagraph":false},{"content":"a big influx of apps in the App Store.","startTime":3647000,"duration":6000,"startOfParagraph":false},{"content":"[CS50.TV]","startTime":3653000,"duration":3000,"startOfParagraph":false}]}