Cocoa

Help

 * http://carterconsulting.org.uk/Articles/

Symbolication
I also put dsym, app bundle, and crash log together in the same directory before running symbolicate crash. Then I use this function defined in my .profile to simplify running symbolicatecrash: function desym {   /Developer/Platforms/iPhoneOS.platform/Developer/Library/PrivateFrameworks/DTDeviceKit.framework/Versions/A/Resources/symbolicatecrash -A -v $1 | more } "Apparently, it found one of your developement build product (for the simulator) and used it to try to symbolicate a crashreport generated on the device. And it failed miserably, of course."
 * http://stackoverflow.com/questions/1460892/symbolicating-iphone-app-crash-reports
 * http://www.eigo.co.uk/Deciphering-iPhone-Crash-Logs.aspx
 * http://www.picsoftware.ca/blog/?p=8
 * http://stackoverflow.com/questions/4669151/analysing-iphone-crash-log
 * http://www.anoshkin.net/blog/2008/09/09/iphone-crash-logs/

Core Animation
"To diagnose this, you could use the Core Animation instrument in Instruments, and select the Color Misaligned Images option. It should color any views or layers that are non-pixel-aligned in your application."
 * http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/InstrumentsUserGuide/Built-InInstruments/Built-InInstruments.html
 * http://stackoverflow.com/questions/2170167/why-does-a-png-image-sometimes-get-blurry-depending-on-its-position-in-a-view

Core Audio

 * http://www.mikeash.com/pyblog/why-coreaudio-is-hard.html
 * http://developer.apple.com/library/mac/#documentation/MusicAudio/Conceptual/CoreAudioOverview/Introduction/Introduction.html
 * http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=midi+cocoa
 * http://ask.metafilter.com/88396/Cocoa-MIDI-how-to
 * http://developer.apple.com/technologies/mac/audio-and-video.html
 * http://developer.apple.com/library/mac/navigation/index.html#topic=Sample+Code&section=Resource+Types
 * http://lists.apple.com/archives/Coreaudio-api/2003/Oct/msg00264.html
 * http://www.cocoadev.com/index.pl?CoreAudio

Books

 * http://www.amazon.com/Core-Audio-Kevin-Avila/dp/0321636848
 * http://www.amazon.com/Audio-Anecdotes-Tools-Techniques-Digital/dp/1568811047/ref=pd_bxgy_b_text_b/002-2490952-4612813?ie=UTF8
 * http://www.amazon.com/Audio-Anecdotes-II-Techniques-Digital/dp/1568812140/sr=8-2/qid=1161327952/ref=sr_1_2/002-2490952-4612813?ie=UTF8&s=books

JSON

 * https://github.com/johnezang/JSONKit

Syncing Stuff

 * http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/SyncServices/Articles/UsingCoreData.html#//apple_ref/doc/uid/TP40005232-SW1

NSString
NSString* newStr = NSString alloc] initWithData:theData                                        encoding:NSUTF8StringEncoding]; // If the data is null-terminated, you should instead use NSString* newStr = [NSString stringWithUTF8String:[theData bytes;
 * http://borkware.com/quickies/one?topic=NSString
 * http://stackoverflow.com/questions/925780/remove-character-from-nsstring-in-iphone-programming
 * http://www.iphonedevsdk.com/forum/iphone-sdk-development/11957-remove-characters-nsstring.html
 * http://forums.macrumors.com/showthread.php?t=500072
 * http://stackoverflow.com/questions/2467844/convert-nsdata-to-nsstring

NSColor
"t is often desirable to store the value of an NSColor instance in an application's user defaults. However, NSUserDefaults only supports the storage of objects that can be represented in an property list. The solution is to use object archiving to write the NSColor instance data to an NSData instance and then store that as the default"
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DrawColor/Tasks/StoringNSColorInDefaults.html

Logging
NSLog(@"Failed to save to data store: %@", [err localizedDescription]); \ NSArray* detailedErrors = [[err userInfo] objectForKey:NSDetailedErrorsKey]; \ if(detailedErrors != nil && [detailedErrors count] > 0) { \ for(NSError* detailedError in detailedErrors) { \ NSLog(@" DetailedError: %@", [detailedError userInfo]); \ } \ } else { \ NSLog(@"  %@", [err userInfo]); \ } \ } while (NO);
 * 1) define LOGERROR(err,msg) do { DLog(@"LOGERROR!"); \

void IFPrint (NSString *format, ...) { va_list args; va_start(args, format);
 * http://stackoverflow.com/questions/3487226/is-it-possible-to-nslog-without-the-time-and-date-stamps-and-the-automatic-new

fputs([[[[NSString alloc] initWithFormat:format arguments:args] autorelease] UTF8String], stdout);

va_end(args); } void DebugLog(NSString *format,...) { va_list ap; va_start (ap, format); if (![format hasSuffix: @"\n"]) { format = [format stringByAppendingString: @"\n"]; }   NSString *body =  [[NSString alloc] initWithFormat: format arguments: ap];    va_end (ap);    fprintf(stderr,"%s",[body UTF8String]);    [body release];  }
 * http://www.karlkraft.com/index.php/2009/03/23/114/
 * http://borkware.com/quickies/one?topic=NSString
 * 1) include 

void LogIt (NSString *format, ...) {   va_list args; va_start (args, format); NSString *string; string = [[NSString alloc] initWithFormat: format arguments: args];    va_end (args);    fprintf (stderr, "%s\n", [string UTF8String]);    [string release]; } // LogIt

Device Orientation
[[UIDevice currentDevice] orientation] // Alternatively, you can request to receive orientation change notifications: [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil]; // Some people also like to check the status bar orientation: [UIApplication sharedApplication].statusBarOrientation
 * http://developer.apple.com/library/ios/#documentation/uikit/reference/UIDevice_Class/Reference/UIDevice.html
 * http://stackoverflow.com/questions/3380539/inaccurate-device-orientation-retuned-by-uideviceorientationdidchangenotification
 * http://stackoverflow.com/questions/3361166/uideviceorientationdidchangenotification-wont-stop
 * http://forums.macrumors.com/showthread.php?t=486957
 * http://stackoverflow.com/questions/2738734/get-current-orientation-of-ipad

iPhone vs iPad
BOOL deviceIsPad = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad); BOOL deviceIsPad = (UI_USER_INTERFACE_IDIOM != UIUserInterfaceIdiomPhone);
 * http://stackoverflow.com/questions/2159951/is-there-a-specific-xcode-compiler-flag-that-gets-set-when-compiling-for-ipad
 * 1) define UI_USER_INTERFACE_IDIOM ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)] ? [[UIDevice currentDevice] userInterfaceIdiom] : UIUserInterfaceIdiomPhone)
 * http://stackoverflow.com/questions/2759229/how-do-i-run-a-universal-app-on-the-iphone-3-1-3-simulator/2759381#2759381

Best Practices

 * http://stackoverflow.com/questions/155964/what-are-best-practices-that-you-use-when-writing-objective-c-and-cocoa#156343

Reflection
[myObject isKindOfClass:[UIImageView class]]; "Note that there is also a isMemberOfClass: method that will check for class 'exactness.' Be careful with it though, as many Apple objects are actually Core Foundation types in disguise. (Eg. an NSString is more often an NSCFString, and isMemberOfClass: will return false for this comparison.)" NSLog(@"======================================="); NSLog(@"Is of type: %@", [element class]); NSLog(@"Is of type NSString?: %@", (element class] isMemberOfClass:[NSString class)? @"Yes" : @"No"); NSLog(@"Is a kind of NSString: %@", (element classForCoder] isSubclassOfClass:[NSString class)? @"Yes" : @"No");
 * http://stackoverflow.com/questions/1144629/in-objective-c-how-do-i-test-the-object-type

NSNumber
NSNumberFormatter * f = NSNumberFormatter alloc] init]; [f setNumberStyle:NSNumberFormatterDecimalStyle]; NSNumber * myNumber = [f numberFromString:@"42"]; [f release]; //American number format - with comma sepparators between thousands NSNumberFormatter *numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; [numberFormatter setFormat:@"; //You will get 123,456,789  NSNumberFormatter also has methods called setPositiveFormat: setNegativeFormat: which replace the depreciated setFormat:
 * http://stackoverflow.com/questions/1448804/how-to-convert-an-nsstring-into-an-nsnumber
 * http://www.iphonedevsdk.com/forum/iphone-sdk-development/5235-decimal-number-format.html
 * http://stackoverflow.com/questions/416037/iphone-nsnumberformatter-setformat
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DataFormatting/Articles/dfNumberFormatting10_4.html
 * http://unicode.org/reports/tr35/tr35-10.html#Number_Format_Patterns

NSDate
+ (NSInteger) minutesUntilDate:(NSDate*) date withTimezoneOffset:(NSInteger) GMTOffset {
 * http://stackoverflow.com/questions/1854890/comparing-two-nsdates-and-ignoring-the-time-component
 * http://stackoverflow.com/questions/2055484/doing-comparison-on-nsdates-in-different-timezones

NSDate *now = [NSDate date]; NSTimeInterval localTimeZoneOffset = [[NSTimeZone defaultTimeZone] secondsFromGMT];

now = [now addTimeInterval:(localTimeZoneOffset * -1)];

date = [date addTimeInterval:(GMTOffset * 60 * 60) * −1];

return ((NSInteger)[now timeIntervalSinceDate:date] / 60 ) * -1; } "NSDate is a reference to an interval from an absolute reference date, January 1, 2001 00:00 GMT. So the class method [NSDate now] will return a representation of that interval. To present that data in a textual format in UTC, just use the NSDateFormatter with the appropriate NSTimeZone (UTC) to render as needed." - (NSDate*) convertToUTC:(NSDate*)sourceDate {   NSTimeZone* currentTimeZone = [NSTimeZone localTimeZone]; NSTimeZone* utcTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
 * http://stackoverflow.com/questions/2615833/objective-c-setting-nsdate-to-current-utc
 * http://stackoverflow.com/questions/1490537/gmt-time-on-iphone

NSInteger currentGMTOffset = [currentTimeZone secondsFromGMTForDate:sourceDate]; NSInteger gmtOffset = [utcTimeZone secondsFromGMTForDate:sourceDate]; NSTimeInterval gmtInterval = gmtOffset - currentGMTOffset;

NSDate* destinationDate = [NSDate alloc] initWithTimeInterval:gmtInterval sinceDate:sourceDate] autorelease];        return destinationDate; } NSDate *myDate = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"GMT";

// Set date style: [dateFormatter setDateStyle:NSDateFormatterShortStyle]; [dateFormatter setTimeStyle:NSDateFormatterShortStyle];

NSString *GMTDateString = [dateFormatter stringFromDate: myDate]; If I am in NY currentGMOffset will be -14400. Since GMT is later than NYC, I want to add a positive value to sourceDate. Also sourceDate has not been modified here. You need sourceDate = [sourceDate addTimeInterval:currentGMTOffset*-1]; which inverts the sign of the offset. + (NSDate *) GMTNow { NSDate *sourceDate = [NSDate date]; NSTimeZone* currentTimeZone = [NSTimeZone localTimeZone]; NSInteger currentGMTOffset = [currentTimeZone secondsFromGMT];

sourceDate = [sourceDate addTimeInterval:(currentGMTOffset*-1)];

return sourceDate; } "An NSDate doesn't have a time zone. NSLog uses your local time zone; it says +0100 because that's where you are." "the date in an NSDate is stored as an absolute date, seconds since 00:00:00 1/1/2001 GMT. So if two people in different timezones store the 'current' date at exactly the same instant, their NSDate's are identical. Timezone is only worked with on retrieval/display, and unless you tell NSDate otherwise it will go with the system locale timezone. In other words, if your two sets of data are stored at the same moment in London and Cupertino, the stored dates are the same, with no difference." A good programming rule of thumb is to always store dates in UTC. It doesn't matter whether you use Core Data or not; you'll still have to do some work because Apple's date classes pretty much suck.
 * http://stackoverflow.com/questions/1232203/how-to-store-dates-without-times-in-core-data

Dates are represented internally as a number of seconds since a reference date which is, I believe, 1 January 2001 00:00:00 (although the actual reference date isn't very important). Point is, NSDate objects are always natively in UTC. If the dates you're getting in your CSV file are local, you'll need to do something like this to get the UTC time:

NSDate *UTCDate = [localDate addTimeInterval:-NSTimeZone localTimeZone] secondsFromGMT;

Then, I'd set the time to 00:00:00. Now you're saving the date, at midnight, in UTC. For presentation purposes, you will use an NSDateFormatter configured with the time zone of your choice (the system time zone is the default if you don't specify one) to display those dates.

Time zones don't really matter when you're just dealing with dates, though. As long as you make sure to set the time zone on your NSDateFormatter to UTC, you'll always show the same date, no matter what time zone the user has selected on her device.

If you don't like this solution, you can always store your dates in an alternative format. You could use a double or int to store the date in some custom format (e.g. the number of days since some reference date), or you could even roll your own class to model the date exactly the way you want and store it as an NSData object. As long as the class implements NSCoding, you can serialize it to an NSData object in Core Data. You just need to set the attribute type in Core Data to "Transformable".

You have a ton of options here, and none of them involve the effort of writing your own SQLite queries and databases.

NSDateFormatter

 * http://www.alexcurylo.com/blog/2009/01/29/nsdateformatter-formatting/
 * http://forums.macrumors.com/showthread.php?t=840292

Bundle
NSString *filePath = NSBundle mainBundle] pathForResource:@"test" ofType:@"xml"]; NSString *filePath = [NSBundle pathForResource:@"event_service_sample" ofType:@"xml" inDirectory:nil]; NSString *filePath = [[NSBundle bundleForClass:[self class pathForResource:@"event_service_sample" ofType:@"xml"]; // app approach // NSBundle *bundle = [NSBundle mainBundle]; NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.fuzzy.UnitTests"]; DLog(@"1 bundle(%@)", bundle); NSURL *url = [bundle URLForResource:@"dbase" withExtension:@"momd"]; DLog(@"1 url(%@)", url);
 * http://iphoneincubator.com/blog/data-management/how-to-read-a-file-from-your-application-bundle

// http://stackoverflow.com/questions/3241175/unit-testing-core-data-exited-abnormally-with-code-134 bundle = [NSBundle bundleWithIdentifier:@"com.fuzzy.UnitTests"]; DLog(@"2 bundle(%@)", bundle); NSString *path = [bundle pathForResource:@"dbase" ofType:@"momd"]; DLog(@"2 path(%@)", path); url = [NSURL URLWithString:path]; DLog(@"2 url(%@)",url); // https://github.com/mbrugger/CoreDataDependentProperties/blob/master/LPAutomatedObserving/Tests/ManagedObjectSenTestCase.m bundle = [NSBundle bundleWithIdentifier:@"com.yourcompany.ApplicationName"]; DLog(@"3 bundle(%@)", bundle); path = [bundle pathForResource:@"boardpaper.momd"]; DLog(@"3 path(%@)", path);

Examples
- (NSFetchedResultsController *)fetchedResultsController { if (fetchedResultsController) return fetchedResultsController; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity =                [NSEntityDescription entityForName:@"FavoriteThing"                            inManagedObjectContext:managedObjectContext];  [fetchRequest setEntity:entity];  NSSortDescriptor *sortDescriptor =               [[NSSortDescriptor alloc] initWithKey:@"displayOrder"                                           ascending:YES];  NSArray *sortDescriptors = [[NSArray alloc]                               initWithObjects:sortDescriptor, nil];    [fetchRequest setSortDescriptors:sortDescriptors];  NSFetchedResultsController *aFetchedResultsController =               [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest                                                   managedObjectContext:managedObjectContext                                                    sectionNameKeyPath:nil cacheName:@"ThingsCache"];  aFetchedResultsController.delegate = self;  [self setFetchedResultsController:aFetchedResultsController];  [aFetchedResultsController release];  [fetchRequest release];  [sortDescriptor release];  [sortDescriptors release];  return fetchedResultsController; }
 * http://www.cimgf.com/2010/06/05/re-ordering-nsfetchedresultscontroller/

anEmployee.department = newDepartment; Alternatively, you can use: [newDepartment addEmployeeObject:anEmployee];
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdAccessorMethods.html
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdRelationships.html
 * http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/CoreData/Articles/cdUsingMOs.html
 * http://stackoverflow.com/questions/1499439/coredata-modeling-relationship-review
 * http://www.cocoabuilder.com/archive/cocoa/198763-core-data-unidirectional-relationships.html
 * http://cocoaconvert.net/tag/core-data/

Migration and Versioning

 * http://www.timisted.net/blog/archive/core-data-migration/

Undo Support

 * http://www.mikeabdullah.net/core_data_undo_management.html

Transient

 * http://www.2pi.dk/tech/cocoa/transient_properties.html

Changes
NSManagedObjectContextObjectsDidChangeNotification
 * http://developer.apple.com/library/mac/documentation/Cocoa/Reference/CoreDataFramework/Classes/NSManagedObject_Class/Reference/NSManagedObject.html#//apple_ref/occ/instm/NSManagedObject/changedValues
 * http://www.cocoabuilder.com/archive/cocoa/206333-core-data-how-to-observe-dirty-state.html

Properties
"Transient properties behave like persistent properties whose value in the persistent store is always nil."
 * http://www.2pi.dk/tech/cocoa/transient_properties.html

NSPredicate

 * https://sites.google.com/a/pintailconsultingllc.com/objective-c-and-cocoa/Home/nspredicate-examples

Multiprocess

 * http://www.cocoabuilder.com/archive/cocoa/291633-core-data-multiuser.html?q=Trumbull+multiuser#291633

Dirty State
NSManagedObjectContextObjectsDidChangeNotification
 * http://www.cocoabuilder.com/archive/cocoa/206333-core-data-how-to-observe-dirty-state.html

KVO

 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html

KVC

 * http://stackoverflow.com/questions/3544541/kvc-array-getters-vs-indexed-accessors
 * http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
 * http://stackoverflow.com/questions/2495484/how-does-nsvalue-do-its-magic/2495620#2495620
 * http://www.tomdalling.com/blog/cocoa/how-cocoa-bindings-work-via-kvc-and-kvo
 * http://cocoawithlove.com/2010/01/5-key-value-coding-approaches-in-cocoa.html
 * http://stackoverflow.com/questions/2495484/how-does-nsvalue-do-its-magic/2495620#2495620
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Protocols/NSKeyValueCoding_Protocol/Reference/Reference.html#//apple_ref/occ/instm/NSObject/mutableSetValueForKey:
 * http://www.cocoabuilder.com/archive/cocoa/194940-kvc-compliance-document-what-if-ivar-in-an-nsset.html
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Protocols/NSKeyValueCoding_Protocol/Reference/Reference.html#//apple_ref/occ/instm/NSObject/mutableSetValueForKey:
 * http://discussions.apple.com/thread.jspa?threadID=2540068
 * http://borkware.com/quickies/one?topic=Core%20Data
 * http://stackoverflow.com/questions/3023126/whats-mutablesetvalueforkey-returning-actually-is-that-something-special
 * http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/KeyValueCoding/Articles/AccessorConventions.html#//apple_ref/doc/uid/20002174-BAJEAIEE

KVC Collections
"Now, in this example, of course you could just call insertObjectInTracks:atIndex: directly, but there are several advantages you can get out of using mutableArrayValueForKey: instead."
 * http://stackoverflow.com/questions/2293448/what-is-the-kvc-search-pattern-for-mutablearrayvalueforkey
 * http://stackoverflow.com/questions/302365/observing-an-nsmutablearray-for-insertion-removal
 * http://stackoverflow.com/questions/3027616/difference-between-mutablearrayvalueforkey-and-calling-insertobjectinemployeesat

Snippets

 * http://cocoaheads.org/quickies/

File IO

 * http://www.servin.com/iphone/iPhone-File-IO.html
 * http://www.iphonedevsdk.com/forum/iphone-sdk-development/18120-serious-question-about-nsdocumentdirectory.html
 * http://stackoverflow.com/questions/272544/whats-the-best-way-to-find-the-users-documents-directory-on-an-iphone
 * http://stackoverflow.com/questions/2717545/how-to-access-the-iphone-library-folder-programmatically
 * http://stackoverflow.com/questions/1567134/how-can-i-get-a-writable-path-on-the-iphone/1567147#1567147
 * http://stackoverflow.com/questions/3762941/getting-an-ios-applications-library-path-reliably

NSFile
"YES if the operation was successful or already exists, otherwise NO." "Attempting to predicate behavior based on the current state of the file system or a particular file on the file system is not recommended. Doing so can cause odd behavior in the case of file system race conditions. It's far better to attempt an operation (such as loading a file or creating a directory), check for errors, and handle any error gracefully than it is to try to figure out ahead of time whether the operation will succeed."
 * http://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/createDirectoryAtPath:withIntermediateDirectories:attributes:error:
 * http://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSFileManager_Class/Reference/Reference.html#//apple_ref/occ/instm/NSFileManager/fileExistsAtPath:isDirectory:
 * http://developer.apple.com/library/ios/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html#//apple_ref/doc/uid/TP40002585
 * http://developer.apple.com/library/ios/documentation/Security/Conceptual/SecureCodingGuide/Introduction.html#//apple_ref/doc/uid/TP40002415

Memory Management
Because UIViewController currently implements its dealloc method using the setView: accessor method (rather than simply releasing the variable directly), self.anOutlet = nil will be called in dealloc as well as in response to a memory warning... This will lead to a crash in dealloc. The remedy is to ensure that outlet variables are also set to nil in dealloc: - (void)dealloc { // release outlets and set variables to nil [anOutlet release], anOutlet = nil; [super dealloc]; } "This answer is correct for Mac OS X, but not for iOS. Take a look at this link under 'Top-Level Objects'. developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/…" "Your IBOutlets are probably @properties. If they are, and you have retain as an attribute, then you do need to release in -dealloc ...If you just use IBOutlet in your interface, you DO NOT need to release them. Reason being is that unless you explicitly retain them in your code, they are merely being set. They stick around because the view is there. Obviously, if you also use properties and retain them, you need to release on dealloc."
 * http://stackoverflow.com/questions/61838/do-i-need-to-release-xib-resources
 * http://stackoverflow.com/questions/382576/do-i-need-to-release-iboutlets-when-using-loadnibnamed-method
 * http://stackoverflow.com/questions/1529350/do-you-have-to-release-iboulets-in-dealloc
 * http://stackoverflow.com/questions/4758724/do-i-need-to-release-iboutlets-in-dealloc

Try Catch Blocks

 * http://macdevcenter.com/pub/a/mac/2007/07/31/understanding-exceptions-and-handlers-in-cocoa.html?page=5

const
The const modifier can be applied to the value, or the pointer to the value. // A constant pointer (not modifiable) to an integer (its value can be modified) int * const // A modifiable pointer to a constant integer (its value can't be modified) const int * // So you can imagine: const int * const;
 * http://stackoverflow.com/questions/3196491/objective-c-const-nsstring-vs-nsstring-const


 * http://stackoverflow.com/questions/538996/constants-in-objective-c

Perform Selector

 * http://blog.jayway.com/2010/03/30/performing-any-selector-on-the-main-thread/

NSNotifications
bool _WebTryThreadLock(bool), 0xe755f0: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now… @interface NSNotificationCenter (MainThread) - (void)postNotificationOnMainThread:(NSNotification *)notification; - (void)postNotificationOnMainThreadName:(NSString *)aName object:(id)anObject; - (void)postNotificationOnMainThreadName:(NSString *)aName object:(id)anObject userInfo:(NSDictionary *)aUserInfo; @end
 * http://www.cilinder.be/docs/next/NeXTStep/3.3/nd/Foundation/Classes/NSNotificationCenter.htmld/index.html
 * Threading problems:
 * http://teknograd.wordpress.com/2009/04/27/spooky-xcode-thread-error/
 * http://forums.macrumors.com/showthread.php?t=707344
 * http://stackoverflow.com/questions/945082/uiwebview-in-multithread-viewcontroller
 * http://www.iphonedevsdk.com/forum/iphone-sdk-development/47583-uitextview-tried-obtain-web-lock-thread-other-than-main-thread.html
 * http://alexyoung.org/2009/06/23/iphone-30-development-glitches/
 * http://www.cocoanetics.com/2010/05/nsnotifications-and-background-threads/

@implementation NSNotificationCenter (MainThread) - (void)postNotificationOnMainThread:(NSNotification *)notification {	[self performSelectorOnMainThread:@selector(postNotification:) withObject:notification waitUntilDone:YES]; } - (void)postNotificationOnMainThreadName:(NSString *)aName object:(id)anObject {	NSNotification *notification = [NSNotification notificationWithName:aName object:anObject]; [self postNotificationOnMainThread:notification]; } - (void)postNotificationOnMainThreadName:(NSString *)aName object:(id)anObject userInfo:(NSDictionary *)aUserInfo {	NSNotification *notification = [NSNotification notificationWithName:aName object:anObject userInfo:aUserInfo]; [self postNotificationOnMainThread:notification]; } @end
 * 1) import "NSNotificationCenter+MainThread.h"
 * http://cocoadev.com/forums/discussion/1464/application-crash-when-use-thread.
 * http://forums.macrumors.com/showthread.php?t=770783

XIBs
"I strongly strongly STRONGLY recommend against frame changes in localizations. I know this runs counter to Apple's advice, but there are SO MANY problems with allowing frame changes - you end up with a billion edge cases."
 * http://weblog.bignerdranch.com/?p=129
 * http://stackoverflow.com/questions/4968738/put-a-uiview-into-a-uitableview-header
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html
 * http://stackoverflow.com/questions/1494999/localizing-a-modern-xib-based-mac-application

Tech Notes

 * http://developer.apple.com/library/mac/navigation/index.html#topic=Technical+Notes&section=Resource+Types

NSThread

 * http://www.cocoadev.com/index.pl?ProducersAndConsumerModel
 * http://www.cocoadev.com/index.pl?NSThread
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSThread_Class/Reference/Reference.html

NSLock

 * http://alienryderflex.com/NSLock.html
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSLock_Class/Reference/Reference.html
 * http://softpixel.com/~cwright/programming/threads/threads.cocoa.php

NSError

 * http://www.cimgf.com/2008/04/04/cocoa-tutorial-using-nserror-to-great-effect/
 * http://www.cimgf.com/2008/05/19/cocoa-tutorial-expanding-nserror-usage/
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSError_Class/Reference/Reference.html

Bindings

 * http://homepage.mac.com/mmalc/CocoaExamples/controllers.html

NSObject

 * http://stackoverflow.com/questions/904515/how-to-use-performselectorwithobjectafterdelay-with-primitive-types-in-cocoa

Atomic

 * http://www.mikeash.com/pyblog/friday-qa-2011-03-04-a-tour-of-osatomic.html

Asynchronous

 * http://stackoverflow.com/questions/1596160/asynchronous-methods-in-nsoperation

Concurrency and NSOperations

 * Dave Dribin's Concurrent Operations Demystified

NSOperationQueue
"It turns out, when you're going to concurrent=NO, you ('typically') need to only override the main function and not all of the others (start, isConcurrent, isExecuting, isFinished)........as it says in the documentation."
 * http://forums.macrumors.com/showthread.php?t=571887

NSOperation
In general you'll get better mileage with NSOperationQueue. Three specific reasons: * You may want to initiate caching of many items at once. NSOperationQueue is smart enough to only create about as many threads as there are cores, queuing the remaining operations. With NSThread, creating 100 threads to cache 100 images is probably overkill and somewhat inefficient. * You may want to cancel the cacheImage operation. Implementing cancellation is easier with NSOperationQueue; most the work is already done for you. * NSOperationQueue is free to switch to a smarter implementation (like Grand Central Dispatch) now or in the future. NSThread is more likely to always be just an operating system thread. Bonus: * NSOperationQueue has some other nice constructs built-in, such as a sophisticated way of honoring operation priorities and dependencies. "Use KVO to observe the operations property of your queue, then you can tell if your queue has completed by checking for [queue.operations count] == 0."
 * http://www.dribin.org/dave/blog/archives/2009/05/05/concurrent_operations/
 * http://stackoverflow.com/questions/3468549/adding-nsoperation-to-nsoperationqueue-that-starts-asynchronous-asihttprequest
 * http://stackoverflow.com/questions/1596160/asynchronous-methods-in-nsoperation
 * http://macresearch.org/node/4567
 * http://asnippet.com/one_snippet.php?command=getSnippet&snippetId=888
 * http://stackoverflow.com/questions/3152155/nsoperationqueue-seems-to-hang-on-completion-for-a-few-seconds
 * http://stackoverflow.com/questions/3041837/nsthread-vs-nsoperationqueue-vs-on-the-iphone
 * http://cocoadev.com/forums/discussion/1703/nsoperationqueue/p1
 * http://stackoverflow.com/questions/1049001/get-notification-when-nsoperationqueue-finishes-all-tasks
 * http://www.mikeash.com/pyblog/dont-use-nsoperationqueue.html
 * http://www.cimgf.com/2008/02/16/cocoa-tutorial-nsoperation-and-nsoperationqueue/
 * http://stackoverflow.com/questions/3404784/how-can-i-make-sure-nsoperations-execute-in-a-failsafe-way
 * https://devforums.apple.com/thread/25282

Multi-threaded
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async(queue, ^ {   Object * obj = [[Object alloc] init];    [obj excuteSync];    // do something    [obj release]; });     dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);    dispatch_async(queue, ^{        __block NSAutoreleasePool *autoReleasePool = [[NSAutoreleasePool alloc] init];        NSURLConnection *connection = [NSURLConnection alloc];        ResponseHandler *handler = [ResponseHandler alloc];
 * http://stackoverflow.com/questions/4154167/rigtht-way-to-implement-aysnchronous-delegate-methods
 * http://www.cocoabuilder.com/archive/cocoa/281178-running-nsurlconnection-from-within-an-nsoperation.html

[handler initWithDelegate:delegate completionBlock:^{dispatch_async(queue, ^{           [connection release];            [handler release];            [autoReleasePool release];            [delegate release];        });}];

[connection initWithRequest:urlRequest delegate:handler startImmediately:NO]; [connection scheduleInRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; [connection start]; });

NTLM

 * http://blog.waynehartman.com/articles/how-to-do-ntlm-authentication-in-ios.aspx
 * http://groups.google.com/group/asihttprequest/browse_thread/thread/92ab63c00481455c
 * https://github.com/pokeb/asi-http-request/issues#issue/52

NSXML

 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/NSXML_Concepts/Articles/NSXMLFeatures.html
 * http://lifeasclay.wordpress.com/2009/12/13/parsing-xml-files-with-objective-c/
 * http://cocoawithlove.com/2008/10/using-libxml2-for-parsing-and-xpath.html
 * http://maniacdev.com/2010/03/iphone-xml-parser-performance-guide/
 * http://jongampark.wordpress.com/2008/06/21/a-few-lines-on-how-to-use-the-nsxmldocument/
 * http://www.raywenderlich.com/553/how-to-chose-the-best-xml-parser-for-your-iphone-project
 * http://www.cimgf.com/2008/08/18/cocoa-tutorial-libxml-and-xmlreader/

NSXMLParser

 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/XMLParsing/XMLParsing.html
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html
 * http://developer.apple.com/library/ios/#documentation/cocoa/reference/NSXMLParserDelegate_Protocol/Reference/Reference.html
 * http://stackoverflow.com/questions/1089737/parsing-xml-in-cocoa/1090170#1090170

NSRunLoop

 * http://bynomial.com/blog/?tag=nsrunloop
 * http://stackoverflow.com/questions/267163/cocoa-nsurlconnection-not-attempting-an-http-request
 * http://stackoverflow.com/questions/3501694/multiple-nsurlconnection-nsrunloop
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Multithreading/RunLoopManagement/RunLoopManagement.html

NSURL
NSURL *url; NSData *data; UIImage *blork; url = [NSURL URLWithString: @"http://langui.net/wp-content/uploads/2011/03/banner.png"]; data = [NSData dataWithContentsOfURL:url]; blork = [[UIImage alloc] initWithData: data]; NSString *myURL = // some URL NSString *fixedURL = [myURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; // or any other encoding NSURL *URL = [NSURL URLWithString:fixedURL];  NSString *myURL = // some URL NSString *fixedURL = [myURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; // or any other encoding NSURL *URL = [NSURL URLWithString:fixedURL];  // file NSDictionary+UrlEncoding.h
 * http://langui.net/2011/03/nsurl-tips/
 * http://borkware.com/quickies/one?topic=NSURL
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURL_Class/Reference/Reference.html
 * http://www.cocoadev.com/index.pl?NSUrl
 * http://www.cocoadev.com/index.pl?NSUrl
 * http://www.iphonedevsdk.com/forum/iphone-sdk-development/11451-conveting-nsstring-nsurl.html
 * http://stackoverflow.com/questions/3345996/nsurl-encoding-using-iso-8859-1-instead-of-utf8
 * http://stackoverflow.com/questions/573010/convert-characters-to-html-entities-in-cocoa
 * 1) import 

@interface NSDictionary (UrlEncoding)

-(NSString*) urlEncodedString;

@end

// file NSDictionary+UrlEncoding.m
 * 1) import "NSDictionary+UrlEncoding.h"

// private helper function to convert any object to its string representation static NSString *toString(id object) { return [NSString stringWithFormat: @"%@", object]; }

// private helper function to convert string to UTF-8 and URL encode it static NSString *urlEncode(id object) { NSString *string = toString(object); return [string stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding]; }

@implementation NSDictionary (UrlEncoding)

-(NSString*) urlEncodedString { NSMutableArray *parts = [NSMutableArray array]; for (id key in self) { id value = [self objectForKey: key]; NSString *part = [NSString stringWithFormat: @"%@=%@", urlEncode(key), urlEncode(value)]; [parts addObject: part]; } return [parts componentsJoinedByString: @"&"]; }

@end

// example

// ... NSMutableDictionary *parameters = [NSMutableDictionary dictionary]; [parameters setValue: @"t" forKey: @"client"]; [parameters setValue: @"auto" forKey: @"sl"]; [parameters setValue: destinationLanguage forKey: @"tl"]; [parameters setValue: text forKey: @"text"]; NSString *urlString = [@"/translate_a/t?" stringByAppendingString: [parameters urlEncodedString]]; @interface NSString (MLExtensions)
 * 1) import "NSDictionary+UrlEncoding.h"

- (NSString *)urlencode;

@end

NSString *_mlfilterChars = @";/?:@&=+$,";

@implementation NSString (MLExtensions)

- (NSString *)urlencode {   return [[NSString stringWithString: (NSString *)        CFURLCreateStringByAddingPercentEscapes(            NULL,             (CFStringRef)self,            NULL,             (CFStringRef)_mlfilterChars,            kCFStringEncodingUTF8)]               stringByReplacingOccurrencesOfString: @"%20" withString: @"+"]; }

@end

// example

- (NSString *)URLForSearch: (NSString *)searchFor {   return [@"http://example.org/search?query=" stringByAppendingString: [searchFor urlencode]]; }
 * http://code.google.com/p/wimframework/source/browse/trunk/WimFramework/Classes/Helpers/WimAdditions.m

NSURLCredential
NSURLCredential *userCredentials = [NSURLCredential credentialWithUser:userName password:password persistence:NSURLCredentialPersistencePermanent];
 * http://cocoadev.com/forums/comments.php?DiscussionID=9

NSURLProtectionSpace *space = [[NSURLProtectionSpace alloc] initWithHost:@"https://api.del.icio.us" port:443 protocol:@"https" realm:@"del.icio.us API" authenticationMethod:nil];

[[NSURLCredentialStorage sharedCredentialStorage] setCredential:userCredentials forProtectionSpace:space];

NSURLCredential *userCredentials = [NSURLCredential credentialWithUser:userName password:password persistence:NSURLCredentialPersistenceForSession]; NSURLProtectionSpace *space = [[NSURLProtectionSpace alloc] initWithHost:@"https://api.del.icio.us"                                                                       port:443                                                                    protocol:@"https"                                                                       realm:@"del.icio.us API"                                                        authenticationMethod:nil];    [[NSURLCredentialStorage sharedCredentialStorage] setCredential:userCredentials                                                 forProtectionSpace:space];    NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.del.icio.us/v1/posts/recent?"]                                                              cachePolicy:NSURLCacheStorageNotAllowed                                                          timeoutInterval:30];    [urlRequest setValue:@"(RedFlag/0.1 (Mac OS X; http://redflagproject.blogspot.com)"      forHTTPHeaderField:@"User-Agent"];    NSURLResponse *response;    NSError *error;    NSData *returnData = [NSURLConnection sendSynchronousRequest:urlRequest                                               returningResponse:&response                                                           error:&error];    [self performSelectorOnMainThread:@selector(processDeliciousDataWithData:)                           withObject:returnData                        waitUntilDone:YES];  - (void)contactDeliciousAndLogin:(id)sender {       NSURLCredential *userCredentials = [NSURLCredential credentialWithUser:userName                                                                  password:password                                                               persistence:NSURLCredentialPersistenceForSession];    NSURLProtectionSpace *space = NSURLProtectionSpace alloc] initWithHost:@"https://api.del.icio.us"                                                                        port:443                                                                    protocol:@"https"                                                                       realm:@"del.icio.us API"                                                        authenticationMethod:nil];    [[NSURLCredentialStorage sharedCredentialStorage] setCredential:userCredentials                                                 forProtectionSpace:space];    NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api.del.icio.us/v1/posts/recent?"]                                                              cachePolicy:NSURLCacheStorageNotAllowed                                                          timeoutInterval:30];    [urlRequest setValue:@"(RedFlag/0.1 (Mac OS X; http://redflagproject.blogspot.com)"      forHTTPHeaderField:@"User-Agent"];    NSURLConnection *connection = [NSURLConnection connectionWithRequest:urlRequest                                                                delegate:self];    [connection start];    [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:10; }
 * http://macsamurai.blogspot.com/2008/03/motherfucker.html

-(void) connection:(NSURLConnection *)conn didDidFailWithError:(NSError *)error {   QLog( @"failed with error: %@", error ); }

-(void) connection:(NSURLConnection *)conn didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {   QLog( @"canceled challenge?" ); }

-(void) connection:(NSURLConnection *)conn didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {   NSLog( @"got a challenge!" ); if( [challenge previousFailureCount] > 2 ) {       NSLog( @"too many failed attempts!" ); NSLog(@"ERROR INFO: %@ ",[challenge error]); NSURLResponse * failedResponce = [challenge failureResponse]; NSLog(@"DEBUG INFO: URL: %@",[failedResponce URL]); NSLog(@"Expected Content Length: %d",[failedResponce expectedContentLength]); NSLog(@"Proposed Credential: %@ | Persistence: %@",[challenge proposedCredential],[[challenge proposedCredential] persistence]);       NSURLProtectionSpace *protSpace = [challenge protectionSpace];        NSLog(@"Protection Space: %@ Host: %@",protSpace);        NSLog(@"Port: %@ Protocol: %@ Realm: %@",[protSpace port],[protSpace protocol],[protSpace realm]);        return;    }

NSURLCredential *userCredentials = [NSURLCredential credentialWithUser:userName password:password persistence:NSURLCredentialPersistencePermanent]; [[challenge sender] useCredential:userCredentials forAuthenticationChallenge:challenge]; }

-(void) connection:(NSURLConnection *)conn didReceiveData:(NSData *)returnData {   QLog(@"Received Network Data... passing it back to the main thread..."); /* Not going to do validation here, just pass this back into the main thread */ [self performSelectorOnMainThread:@selector(processDeliciousDataWithData:) withObject:returnData waitUntilDone:YES]; }

NSURLConnection
@interface TTURLConnection : NSURLConnection { NSHTTPURLResponse* _response; NSMutableData* _responseData; }
 * http://developer.apple.com/library/ios/#samplecode/AdvancedURLConnections/Listings/UI_Building_Blocks_AuthenticationController_m.html#//apple_ref/doc/uid/DTS40009558-UI_Building_Blocks_AuthenticationController_m-DontLinkElementID_26
 * http://stackoverflow.com/questions/405151/is-it-possible-to-prevent-an-nsurlrequest-from-caching-data-or-remove-cached-data
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html
 * http://stackoverflow.com/questions/791177/no-data-returned-using-nsurlconnection-asynchronously
 * http://www.cocoabuilder.com/archive/cocoa/281178-running-nsurlconnection-from-within-an-nsoperation.html
 * Async NSURLConnection + Concurrent NSOperation = Not possible
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/Tasks/UsingNSURLConnection.html
 * http://allseeing-i.com/ASIHTTPRequest/
 * http://www.goosoftware.co.uk/blog/adding-state-to-nsurlconnection/
 * http://stackoverflow.com/questions/1192294/cocoa-checks-required-for-multiple-asynchronous-nsurlconnections-using-same-dele

@property(nonatomic,retain) NSHTTPURLResponse* response; @property(nonatomic,retain) NSMutableData* responseData;

@end

@implementation TTURLConnection

@synthesize response = _response, responseData = _responseData;

- (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate { NSAssert(self != nil, @"self is nil!");

// Initialize the ivars before initializing with the request // because the connection is asynchronous and may start // calling the delegates before we even return from this // function.

self.response = nil; self.responseData = nil;

self = [super initWithRequest:request delegate:delegate]; return self; }

- (void)dealloc { [self.response release]; [self.responseData release];

[super dealloc]; }

@end

///////////////////////////////////////////////////////////////// ////// NSURLConnectionDelegate

- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSHTTPURLResponse*)response { TTURLConnection* ttConnection = (TTURLConnection*)connection; ttConnection.response = response; ttConnection.responseData = [NSMutableData dataWithCapacity:contentLength]; }

- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data { TTURLConnection* ttConnection = (TTURLConnection*)connection; [ttConnection.responseData appendData:data]; }

- (void)connectionDidFinishLoading:(NSURLConnection *)connection { TTURLConnection* ttConnection = (TTURLConnection*)connection;

if (ttConnection.response.statusCode == 200) { // Connection success } }

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { TTURLConnection* ttConnection = (TTURLConnection*)connection; // Handle the error }

connectionToInfoMapping = CFDictionaryCreateMutable(       kCFAllocatorDefault,        0,        &kCFTypeDictionaryKeyCallBacks,        &kCFTypeDictionaryValueCallBacks);
 * http://stackoverflow.com/questions/332276/managing-multiple-asynchronous-nsurlconnection-connections

// It may seem odd to use this instead of NSMutableDictionary but I do it because this CFDictionary only retains its keys (the NSURLConnection) whereas NSDictionary copies its keys (and NSURLConnection doesn't support copying). Once that's done:

CFDictionaryAddValue(   connectionToInfoMapping,    connection,    [NSMutableDictionary        dictionaryWithObject:[NSMutableData data]        forKey:@"receivedData"]);

// and now I have an "info" dictionary of data for each connection that I can use to track information about the connection and the "info" dictionary already contains a mutable data object that I can use to store the reply data as it comes in.

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {   NSMutableDictionary *connectionInfo = CFDictionaryGetValue(connectionToInfoMapping, connection); [[connectionInfo objectForKey:@"receivedData"] appendData:data]; } I have a project where I have two distinct NSURLConnections, and wanted to use the same delegate. What I did was create two properties in my class, one for each connection. Then in the delegate method, I check to see if which connection it is - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {    if (connection == self.savingConnection) {        [self.savingReturnedData appendData:data];    }    else {        [self.sharingReturnedData appendData:data];    } }

- (void)load { NSURL *myURL = [NSURL URLWithString:@"http://stackoverflow.com/"]; NSURLRequest *request = [NSURLRequest requestWithURL:myURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; }
 * http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/URLLoadingSystem/Concepts/URLOverview.html
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html
 * http://stackoverflow.com/questions/704985/objective-c-asynchronous-web-request-with-cookies

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { responseData = [[NSMutableData alloc] init]; }

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [responseData appendData:data]; }

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { [responseData release]; [connection release]; // Show error message }

- (void)connectionDidFinishLoading:(NSURLConnection *)connection { // Use responseData [responseData release]; [connection release]; }

// You can use the NSURLConnection class to perform a HTTP request to login the website, and retrieve the cookie. // To perform a request, just create an instance of NSURLConnection and assign a delegate object to it.
 * http://stackoverflow.com/questions/2053568/managing-http-cookies-on-iphone

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/"]]; NSURLConnection *connection = [NSURLConnection connectionWithRequest:request delegate:self];

// Then, implement a delegate method.

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {   NSHTTPURLResponse *HTTPResponse = (NSHTTPURLResponse *)response; NSDictionary *fields = [HTTPResponse allHeaderFields]; NSString *cookie = [fields valueForKey:"Set-Cookie"]; // It is your cookie }

// Retain or copy the cookie string. When you want to perform another request, add it to your HTTP header of your NSURLRequest instance.

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com/"]]; [request addValue:cookie forHTTPHeaderField:"Cookie"];

NSData
NSData *xmlData = ; "Great sample code: CocoaHTTPServer, CocoaSOAP, SimplePing, Sketch-112, UDPEcho" NSString* newStr = NSString alloc] initWithData:theData encoding:NSUTF8StringEncoding]; // If the data is null-terminated, you should instead use NSString* newStr = [NSString stringWithUTF8String:[theData bytes; NSRange range = NSMakeRange(0, [theData length]); [xmlData appendString:[NSString stringWithUTF8String:theData subdataWithRange:range] bytes];
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/Reference/Reference.html
 * http://stackoverflow.com/questions/2467844/convert-nsdata-to-nsstring

NSRange

 * http://iphonedevelopertips.com/cocoa/nsrange-and-nsstring-objects.html

Security

 * https://github.com/pokeb/asi-http-request/issues#issue/52
 * http://developer.apple.com/library/mac/#technotes/tn2002/tn2095.html
 * CocoaEncryption

Style, Guidelines, Patterns

 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaFundamentals/CocoaDesignPatterns/CocoaDesignPatterns.html
 * http://cocoadevcentral.com/articles/000082.php
 * http://iphone2009.crowdvine.com/system/talks/presentations/000/005/106/Buck_-_Cocoa_Design_Patterns.pdf?1289428795

Document Based Applications

 * http://www.cocoarocket.com/articles/mydocument.html
 * http://lists.apple.com/archives/cocoa-dev/2005/Dec/msg01809.html
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Documents/Concepts/RolesOfDocObjects.html
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSDocument_Class/Reference/Reference.html#//apple_ref/occ/instm/NSDocument/makeWindowControllers

PDFs

 * http://developer.apple.com/cocoa/pdfkit.html

People

 * http://masters-of-the-void.com/book8.htm
 * http://joshua.nozzi.name/2009/10/jlndrageffectmanager/
 * http://quatermain.tumblr.com/

Tuts

 * http://www.mactech.com/articles/mactech/Vol.13/13.09/MyFirstYellowBoxApp/index.html

NSSplitView

 * http://cocoawithlove.com/2009/09/nssplitview-delegate-for-priority-based.html

NSBrowser

 * http://www.cocoadev.com/index.pl?NSBrowser
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Browser/Browser.html
 * http://6tringle.com/blog/2006/core-data-nsbrowser-01.html

NSOutlineView

 * http://developer.apple.com/library/mac/#samplecode/SourceView/Introduction/Intro.html
 * http://www.stupendous.net/archives/2009/01/11/nsoutlineview-example/
 * NSOutlineViewDataSource
 * http://www.bleepsoft.com/tyler/index.php?itemid=9
 * http://theocacao.com/document.page/130/

NSTreeController

 * http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSTreeController_Class/Reference/Reference.html
 * http://stackoverflow.com/questions/1678637/how-do-i-use-nstreecontroller-nsoutlineview-and-core-data-with-an-invisible-ro
 * http://cocoadev.com/index.pl?NSTreeController
 * http://www.bleepsoft.com/tyler/index.php?itemid=9
 * http://jonathandann.wordpress.com/2008/04/06/using-nstreecontroller/
 * http://designedrecreations.blogspot.com/2009/04/cocoa-nstreecontroller-and-nstreenode.html
 * http://blog.latenightsw.com/?p=413
 * http://jonathandann.wordpress.com/2008/05/13/nstreecontroller-and-core-data-sorted/
 * http://stackoverflow.com/questions/3079839/nsoutlineview-nstreecontroller-and-a-heterogeneus-hierarchy

Rule Editor

 * http://code.google.com/p/ruleeditor/

Cocoa Bindings

 * http://developer.apple.com/library/mac/#documentation/cocoa/conceptual/CocoaBindings/Concepts/CntrlContent.html#//apple_ref/doc/uid/TP40002147-185041
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaBindings/CocoaBindings.html
 * http://cocoadevcentral.com/articles/000080.php
 * http://homepage.mac.com/mmalc/CocoaExamples/controllers.html
 * http://www.cocoadev.com/index.pl?CocoaBindings
 * http://stackoverflow.com/questions/595188/what-describes-objective-c-and-cocoa-bindings-best
 * http://www.macresearch.org/tutorial_cocoa_bindings_and_value_transformers

NSToolbar

 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Toolbars/Concepts/HowTBsCreated.html
 * http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Toolbars/Articles/ToolbarInIB.html
 * http://www.dikant.de/2007/09/05/nstoolbar-basics/
 * http://cocoadev.com/index.pl?NSToolbar

NSToolbarItem

 * http://www.cocoadev.com/index.pl?NSToolbarItem
 * http://developer.apple.com/library/mac/#documentation/cocoa/reference/ApplicationKit/Classes/NSToolbarItem_Class/Reference/Reference.html

NSDrawer

 * http://www.stone.com/The_Cocoa_Files/More_or_Less.html
 * http://www.omnigroup.com/mailman/archive/macosx-dev/2000-June/014392.html
 * http://homepage.mac.com/simx/technonova/rants/in_defense_of_the_nsdrawer.html