Developing iOS7 Apps for iPhone and iPad Notes [Updating]
Class #1 – Class Logistics, Overview of iOS, MVC, Objective-C
MVC communication
In Single MVC System
-
View -> Controller
- target – action
- delegate : (will,should, did)
- data source : data at, count
-
Model -> Controller
- Notification
- KVO
In Multiple MVCs System
Property
- A “Property” is just the combination of a getter method and a setter method in a class
- All object in Objective-C is stored in the heap
“Strong v.s Weak”
Strong
means keep the memory for the thing this points to, in the heap, as long as I or anyone else has a strong pointer to it.Weak
means a pointer to this thing in the heap and keep it in memory as long as some else has a strong pointer to it.But as soon as no one else has a strong pointer to that thing, it gets freed from memory and this pointer set tonil
(Nil means this points doesn’t point to anything)- Check the Example
Setter / Getter
- we do not have to implement setter/getter and
@synthesize ....
line, Xcode put them default (not showing) - we could modify the getter method name, for example :
@property (nonatomic, getter = isChosen) BOOL chosen;
Class #2 – Xcode 5
NSUInteger v.s unsigned int
- They are almost same thing
- The only thing about NSU integer is it’s
typedef
. - For example,
- The new iPhone 5s are 64-bit processers, so NSU integer is going to be 64-bit unsigned int on an iPhone 5s.
- Only about a 32-bit one back on an iPhone4 and before.
instancetype
- New feature in iOS 7
- Return an object that is of the same instance, same class type as the object you sent this message to.
UILabel is weak
for its controller
- the View will point its UILabel strongly, so the controller doesn’t have to.