Sunday, May 25, 2014

iOS Tutorial - Part 10 - Review

Review


Video Description 

Warnings

Xcode shows warning with yellow rectangle at the beginning of the line of the code that has problem. You can see the description of the warning by clicking on the rectangle. If the description of the warning is more than a line, you can hover the warning to show the full description of the warning.
In order to force the Xcode compiler to have a warning, we can use #warning message like bellow:
#warning Description of the warning

Errors

Xcode shows compile errors with red signs. The build will fail if application contains any error.

(nonatomic, strong)

nonatomic: Not thread safe. You can read the full description of this attribute here
strong: Strong pointer to an object. It means keep the memory for the thing that this property points to, in the heap,as long as I or anyone else has strong pointer to it. Full description could be found here
weak: Weak pointer to an object.

#import

In order to include other classes or other frameworks we use #import. We import only .h files. The format for importing classes is as follow:
#import "ViewController.h"
The format for importing a framework is as follow:
#import ""

Why self?

If you define a property and you want to call that property, you need to use self at the beginning of the name of the property. For local or instance variables we don't need to use self. If you are familiar with Java development, self is more like this in Java.

Dot notations and square bracket notation

You may have noticed dot notations in objective-c. They both do the same thing, accessing the methods.Use dot notation only for setters and getters, but for calling a method, use square bracket notation.
self.myTextField.text.length
The equivalent for the above line is as follow:
[[[self myTextField] text] length];
We can use the combination of dot notation and bracket notation like bellow:
[self.myTextField.text length];

MVC

Model-View-Controller
Full explanation of MVC design pattern in objective-c can be found here (Minute 14:18 until 26:00).

No comments:

Post a Comment