Objective-C

General

 * http://en.wikibooks.org/wiki/Cocoa_Programming/Objective-C_basics
 * http://cocoadevcentral.com/d/learn_objectivec/

Volatile

 * http://publications.gbdirect.co.uk/c_book/chapter8/const_and_volatile.html

Properties

 * http://stackoverflow.com/questions/1933489/objective-c-2-0-properties-why-both-retain-and-readonly
 * http://cocoacast.com/?q=node/103

Blocks

 * http://pragmaticstudio.com/blog/2010/7/28/ios4-blocks-1
 * http://spicedcocoa.wordpress.com/2010/06/16/working-with-blocks-in-objective-c/
 * http://thirdcog.eu/pwcblocks/

Protocols

 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Chapters/ocProtocols.html

id vs NSObject
id foo1; NSObject *foo2; id foo3;
 * http://stackoverflow.com/questions/2891411/what-is-the-different-between-an-id-and-nsobject-in-objective-c#2891435
 * http://stackoverflow.com/questions/679822/why-tack-a-protocol-of-nsobject-to-a-protocol-implementation

Categories
"I want to emphasize, that, according to Apple, using categories to overwrite methods is wrong. It is unlikely, but your code a) might crash on future platforms/with future SDKs and b) could theoretically be rejected from the AppStore. You should read the guidelines for categories, it sais: 'Although the language currently allows you to use a category to override methods the class inherits, or even methods declared in the class interface, you are strongly discouraged from using this functionality. A category is not a substitute for a subclass.'"
 * http://stackoverflow.com/questions/4075704/uitoolbar-categories-drawrect-wont-work

Exception Handling

 * http://macdevcenter.com/pub/a/mac/2007/07/31/understanding-exceptions-and-handlers-in-cocoa.html?page=5
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Exceptions/Tasks/HandlingExceptions.html

Structs

 * http://stackoverflow.com/questions/2172887/use-c-struct-in-objective-c

Malloc
int *array = malloc(sizeof(int) * 100); memset(array,0,sizeof(int) * 100); // use the array free(array);
 * http://stackoverflow.com/questions/971249/how-to-find-the-cause-of-a-malloc-double-free-error
 * http://stackoverflow.com/questions/1150650/is-it-ok-to-use-classic-malloc-free-in-objective-c-iphone-apps

Linux

 * http://orangejuiceliberationfront.com/playing-with-objective-c-on-debian/

Unit Testing

 * http://stackoverflow.com/questions/4777342/how-to-handle-memory-management-for-custom-modal-dialog-setup-teardown

Singletons
+ (Config)sharedConfig { static Config *singleton = nil; // fast check if (!singleton) { // slow check @synchronized(self) { // double check that someone didn't beat us here if (!singleton) { singleton = [Config new]; }		}	}	return singleton; } "+initialize may be called more than once ..." static MySingleton *sharedSingleton;
 * http://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSObject_Class/Reference/Reference.html
 * http://stackoverflow.com/questions/2362838/iphone-is-there-a-class-teardown-counterpart-to-initialize
 * http://www.friday.com/bbum/2009/09/06/iniailize-can-be-executed-multiple-times-load-not-so-much/
 * http://stackoverflow.com/questions/521102/objective-c-singleton-instance-as-a-static
 * http://getsetgames.com/2009/08/30/the-objective-c-singleton/
 * http://numbergrinder.com/node/29
 * http://stackoverflow.com/questions/145154/what-does-your-objective-c-singleton-look-like

+ (void)initialize {   static BOOL initialized = NO; if(!initialized) {       initialized = YES; sharedSingleton = [[MySingleton alloc] init];   } }  static void * volatile sharedInstance = nil;

+ (className *) sharedInstance { while (!sharedInstance) { className *temp = [[self alloc] init];                                                                    if(!OSAtomicCompareAndSwapPtrBarrier(0x0, temp, &sharedInstance)) {      [temp release];                                                                                       }                                                                                                      }                                                                                                          return sharedInstance;                                                                        }  static MyClass *gInstance = NULL;

+ (MyClass *)sharedMyClass {    if(gInstance) return gInstance;

@synchronized(self) {       if (gInstance == NULL) gInstance = [[self alloc] init];   }    return gInstance; }  + (id)sharedFoo {    static dispatch_once_t once;    static MyFoo *sharedFoo;    dispatch_once(&once, ^ { sharedFoo = [[self alloc] init]; });    return sharedFoo; }


 * http://cocoawithlove.com/2008/11/singletons-appdelegates-and-top-level.html
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaObjects/CocoaObjects.html#//apple_ref/doc/uid/TP40002974-CH4-SW32

General

 * http://en.wikipedia.org/wiki/Objective-C
 * http://google-styleguide.googlecode.com/svn/trunk/objcguide.xml
 * http://www.openscenegraph.org/projects/osg/wiki/Support/PlatformSpecifics/Objective-C
 * http://stackoverflow.com/questions/2172887/use-c-struct-in-objective-c
 * http://cocoadevcentral.com/articles/000083.php
 * http://www.otierney.net/objective-c.html

Primers

 * http://www.theocacao.com/document.page/510
 * http://developer.apple.com/iphone/library/referencelibrary/GettingStarted/Learning_Objective-C_A_Primer/
 * http://www.otierney.net/objective-c.html
 * http://en.wikibooks.org/wiki/Objective-C_Programming/in_depth
 * http://stackoverflow.com/questions/626898/how-do-i-create-delegates-in-objective-c

Guidelines

 * static method names start with CapitalLetter
 * http://cocoawithlove.com/2009/06/method-names-in-objective-c.html

Enumerations
In C and Objective-C (but not C++), any references to this must be preceded with the enum keyword. For example: enum tagname x; // declare x of type 'enum tagname' tagname x; // ERROR in C/Objective-C, OK in C++ In order to avoid having to use the enum keyword everywhere, a typedef can be created: enum tagname { ... }; typedef enum tagname tagname;
 * http://stackoverflow.com/questions/707512/typedef-enum-in-objective-c

Properties

 * http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/7295-getters-setters-properties-newbie.html
 * http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProperties.html
 * https://devforums.apple.com/message/276967#276967
 * http://macdevelopertips.com/objective-c/objective-c-properties-setters-and-dot-syntax.html
 * http://stackoverflow.com/questions/588866/atomic-vs-nonatomic-properties
 * http://stackoverflow.com/questions/3277258/beyond-narc-when-to-retain-when-to-assign-when-to-copy
 * http://stackoverflow.com/questions/4270179/atomic-vs-nonatomic-when-to-use-in-objective-c-ios

Profiling

 * http://www.informit.com/articles/article.aspx?p=1229351&seqNum=3
 * http://stackoverflow.com/questions/1276549/shark-mallocdebug-for-iphone-applications

Memory Management
"Once NSZombie reports access to a deallocated object you can use malloc_history to work out when the object was allocated." "With NSZombieEnabled, Cocoa sets an object's isa pointer to the NSZombie class when its retain count drops to zero instead of deallocating it. Then when you send a message to an NSZombie object (i.e., you're accessing freed data), it raises an exception and tells you where the object lives:" "Click on the 'Targets' tab, open 'Executables' and select the app (In XCode 2.0, double-click the executable in the file tree and select the arguments tab to enter environment variables). In the executable settings, add the following environment variables and set their values to 'YES' (without the quotes):" NSDebugEnabled NSZombieEnabled MallocStackLogging MallocStackLoggingNoCompact
 * http://stackoverflow.com/questions/945984/how-to-tell-when-object-is-sent-release-message
 * http://www.corbinstreehouse.com/blog/2007/10/instruments-on-leopard-how-to-debug-those-random-crashes-in-your-cocoa-app/
 * http://www.cocoadev.com/index.pl?MemoryManagement
 * http://www.cocoadev.com/index.pl?DebuggingAutorelease

Here is a list of break points to put in ~/.gdbinit that are really helpful in debugging memory problems: fb -[NSException raise] fb - fb -
 * http://www.cocoadev.com/index.pl?NSZombieEnabled

set env MallocHelp=YES set env NSZombieEnabled=YES set env NSDeallocateZombies=NO set env MallocCheckHeapEach=100000 set env MallocCheckHeapStart=100000 set env MallocScribble=YES set env MallocGuardEdges=YES set env MallocCheckHeapAbort=1
 * 1) define NSZombies
 * 2) this will give you help messages.  Set to NO to turn them off.
 * 1) might also be set in launch arguments.

set env CFZombie 5

fb -[_NSZombie init] fb -[_NSZombie retainCount] fb -[_NSZombie retain] fb -[_NSZombie release] fb -[_NSZombie autorelease] fb -[_NSZombie methodSignatureForSelector:] fb -[_NSZombie respondsToSelector:] fb -[_NSZombie forwardInvocation:] fb -[_NSZombie class] fb -[_NSZombie dealloc]

fb szone_error

MallocStackLogging
"This is an environment variable. When this environment variable is set, with 'setenv MallocStackLogging 1' in tcsh (for example), then you can launch any app in that shell. Do not 'open' the app, launch it from the shell. When you do this all mallocs are tracked. Then saying, in another shell, 'leaks ' or 'leaks ' will give you a potentially voluminous list of the leaks in the app at that point."
 * http://www.cocoadev.com/index.pl?MallocStackLogging

Selectors
[self performSelector:@selector(myTestWithAString:) withObject:myString];
 * http://developer.apple.com/mac/library/documentation/cocoa/conceptual/objectivec/articles/ocSelectors.html
 * http://stackoverflow.com/questions/1090854/invoking-an-objective-c-method-by-name
 * http://stackoverflow.com/questions/1018195/objective-c-calling-selectors-with-multiple-arguments
 * http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html

Protocols

 * http://www.informit.com/articles/article.aspx?p=1272498&seqNum=2
 * http://developer.apple.com/mac/library/documentation/cocoa/conceptual/objectivec/articles/ocProtocols.html
 * http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Protocols/NSObject_Protocol/Reference/NSObject.html
 * http://stackoverflow.com/questions/322498/how-to-create-a-protocol-with-methods-that-are-optional

Memory
"Generally, copying an object involves creating a new instance and initializing it with the values in the original object."
 * http://developer.apple.com/iphone/library/documentation/cocoa/conceptual/memorymgmt/Articles/mmImplementCopy.html

objc_msgSend

 * http://bencoffman.com/blog/CommentView,guid,054403bc-fa5b-44b0-9dd2-e8150e71c9ed.aspx
 * http://ridiculousfish.com/blog/archives/2005/08/01/objc_msgsend/
 * http://blog.copilot.com/2008/09/debugging-objc_.html
 * http://www.friday.com/bbum/2009/12/18/objc_msgsend-part-1-the-road-map/
 * http://www.sealiesoftware.com/blog/archive/2008/09/22/objc_explain_So_you_crashed_in_objc_msgSend.html

Var Args

 * http://cocoawithlove.com/2009/05/variable-argument-lists-in-cocoa.html
 * http://stackoverflow.com/questions/710033/what-is-this-objective-c-syntax-ellipse-style-dot-notation
 * http://developer.apple.com/mac/library/qa/qa2005/qa1405.html
 * http://numbergrinder.com/node/35
 * 1) import 

@interface NSMutableArray (variadicMethodExample)

- (void) appendObjects:(id) firstObject, ...; // This method takes a nil-terminated list of objects.

@end

@implementation NSMutableArray (variadicMethodExample)

- (void) appendObjects:(id) firstObject, ... { id eachObject; va_list argumentList; if (firstObject)                     // The first argument isn't part of the varargs list, {                                  // so we'll handle it separately. [self addObject: firstObject]; va_start(argumentList, firstObject);         // Start scanning for arguments after firstObject. while (eachObject = va_arg(argumentList, id)) // As many times as we can get an argument of type "id" [self addObject: eachObject];              // that isn't nil, add it to self's contents. va_end(argumentList); } }

@end
 * http://justinsboringpage.blogspot.com/2007/12/c-passing-on-variadic-function.html
 * http://stackoverflow.com/questions/695982/passing-an-ellipsis-to-another-variadic-function
 * http://stackoverflow.com/questions/2345196/objective-c-passing-around-nil-terminated-argument-lists
 * http://stackoverflow.com/questions/4703877/how-to-pass-variable-number-of-args-to-a-variadic-function