Objective-C

TwitterFacebook
Get flash to fully experience Pearltrees
blocks

Analyse ObjC code

http://cocoawithlove.com/2010/03/dynamic-ivars-solving-fragile-base.html Introduction The post is about dynamic ivars in Objective-C. Dynamic ivars exist to solve a common type of fragile base class, specifically, the problem of ivar layouts. A fragile base class problem is a situation where a minor change to the base class can break subclasses. The ivar layout problem is a fragile base class problem where you can't add an ivar to a base class without requiring all subclasses to be recompiled.

Cocoa with Love: Dynamic ivars: solving a fragile base class problem

http://stackoverflow.com/questions/918698/why-are-objective-c-delegates-usually-given-the-property-assign-instead-of-retai Because the object sending the delegate messages does not own the delegate. Many times, it's the other way around, as when a controller sets itself as the delegate of a view or window: the controller owns the view/window, so if the view/window owned its delegate, both objects would be owning each other. This, of course, is a retain cycle, similar to a leak with the same consequence (objects that should be dead remain alive). Addendum (added 2012-05-19): Under ARC, you should use weak instead of assign . Weak references get set to nil automatically when the object dies, eliminating the possibility that the delegating object will end up sending messages to the dead delegate. If you're staying away from ARC for some reason, at least change assign properties that point to objects to unsafe_unretained , which make explicit that this is an unretained but non-zeroing reference to an object.

Assign vs. retain for Objective-C delegates

naming & code style

static in Objective-C means a different thing than static in a C++ class, in the context of static class data members and static class methods. In C and Objective-C, a static variable or function at global scope means that that symbol has internal linkage . Internal linkage means that that symbol is local to the current translation unit , which is the current source file ( .c or .m ) being compiled and all of the header files that it recursively includes. That symbol cannot be referenced from a different translation unit, and you can have other symbols with internal linkage in other translation units with the same name. http://stackoverflow.com/questions/7642304/objective-c-static-extern-public-variables

Objective-C static, extern, public vars