Last active
August 29, 2015 14:05
-
-
Save trivektor/54c3bf83a59a0215eb12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Protocol | |
------------ | |
Protocol in Objective-C is like interface in Java | |
Apple tends to favor using subclasses than protocol | |
NSObject is a class but also a protocol | |
Category | |
------------ | |
Categories not allow to add properties to classes | |
@interface CCBird(<Category Name>) | |
@end | |
Associate Object | |
----------------- | |
An object that is associated with another object | |
Memory | |
--------- | |
Automatic referece counting | |
Weak reference | |
When using nonatomic, strong is also implied | |
Child pointing to a parent should always use a weak reference | |
When a property is synthesized, it will call copy on the property | |
When calling copy on a mutable object, we get back an immutable object | |
NSString is a cluster class (having multiple definitions of it) | |
assign is usually used with primitive | |
@autoreleasepool | |
Rule of thumb | |
-------------- | |
Stays at the highest level of abstraction as possible. | |
UIKit > Core Animation > Core Graphics > OpenGL ES (UIKit is the highest level of abstraction) | |
Parsing string is expensive in iOS | |
Drawing distances are measured in points | |
Screen dimensions are measured in pixels | |
Retina screen: 2 pixels make 1 point | |
Frame: size and location of a view in its superview's coordinate system | |
Bounds: size of the view and its content origin in its local coordinate system | |
Transform: affine transform applied to the view's coordinate system relative to the view's center property. | |
convertPoint:(CGPoint *)srcPoint fromView:(UIView *)srcView | |
setNeedsLayout: will percolate down to child views | |
Avoid using drawRect for performance sake | |
CGRect is a struct not an object so we don't need a * when declaring it | |
UIScreen's application frame is everything excluding the 20px of the navigation bar where as bounds gives us everything. | |
Application frame is different between iOS 6 and 7 | |
self.view will create a view | |
Delegate should be a weak reference because it has a pointer to the view controller | |
[[NSNotification defaultCenter] removeObserver:self] | |
Main Thread | |
--------------- | |
UI Event Run Loop | |
NSThread | |
Threads are expensive (512k of stack / 90 microseconds creation time) | |
Grand Central Dispatch is much better than Threads | |
NSOperationQueue | |
@synchronized | |
typeof(self) | |
Core Animation Framework | |
------------------------- | |
Every UIView has a layer | |
Cocoa supports layers but they're not turned on by default | |
Animation | |
---------- | |
CGRect is an animatable property | |
Forward declaration | |
UIRefreshControl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment