ios day three

Posted on May 14, 2013 ios sait

MVC (Model View Controller)

  • Model means data.
  • View means view or screen.
  • Controller means controller.

Every view has a controller, but not every controller has a view. Some special controllers, that we call controller of controllers are used in Xcode.

Connecting a view to a controller

Do some drag and drop stuff. Ctrl+click and drag UI elements to the code editor (this seems like a good idea… sarcasm intended).

IBOutlet is a keyword that allows teh view to see the code and connect to it.

IBAction has the same value as void. It is a keyword that allows the button to see the code and connect to it.

-(IBAction)firstButton:(id)sender {

Simulator Rotation

If you press Command+left or Command+right it will rotate the simulator. You can turn this off by unchecking “Use Autolayout” in the File Inspector for the .xib file.

The view wont rotate when the phone is upside down. Apple doesn’t want you to be playing a game or using an app with the phone upside down.


Objective-C has several different types of collections.

  • Arrays
  • Sets
  • Dictionaries

Collections can only contain references to objects.


is immutable, which means it must be completely populated when it’s instantiated.

  NSArray * items = [[NSArray alloc] initWithObjects:@"ruby", @"c", @"c#", nil];

nil terminal is necessary. That is how the array will know what size it will be.

To store an integer into an array:

  NSArray * numbers = [[NSArray alloc] initWithObjects:[NSNumber
  [[numbers objectAtIndex:0] intValue];


Is mutable, so you can push objects into it or pop object off of it.


Controls are how we input data into our application, and view the data from our app.


The view is always controlled by the ViewController. It is the file owner.


Touch Up Inside: When you touch the button and lift your finger off the button. Basically a click event.

44 - Magic Number

44x44 is the minimum area for when someone is tapping something.