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
#import "stdio.h" | |
// clang -g -Wall -o scanstop scanstop.m | |
static short intArray[] = { 1, 1, 2, 3, 5, 7, 12, 19, 31 }; | |
static char *ravenArray[] = { "once", "upon", "a", "midnight", "dreary" }; | |
typedef struct Groovy { | |
int value; |
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
#import <Foundation/Foundation.h> | |
// clang -fobjc-arc -Wall -Wformat -Weverything -Wno-format-nonliteral -framework Foundation -o log log.m | |
// Compiler likes explicit function prototypes prior to first use. | |
// Add an attribute to get additional checking from the compiler | |
extern void QuietLog (NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); | |
// !!! The attribute above isn't warning like it should, but NSLog's _is_ working. | |
// This is NSLog's attribute. I'm currently baffled. |
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
#import <Foundation/Foundation.h> | |
// clang -Weverything -framework Foundation -o string-fun string-fun.m | |
int main (void) { | |
@autoreleasepool { | |
{ | |
// Split and join | |
NSString *splitString = @"hello:-(there:-(everybody"; |
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
// | |
// NSObject+setValuesForKeysWithJSONDictionary.h | |
// SafeSetDemo | |
// | |
// Created by Tom Harrington on 12/29/11. | |
// Copyright (c) 2011 Atomic Bird, LLC. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
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
#import <Foundation/Foundation.h> | |
// clang -g -fobjc-arc -Wall -framework Foundation -o unsafe unsafe.m | |
@interface NSThing : NSObject | |
@end | |
@implementation NSThing | |
- (void) dealloc { |
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
#import <Foundation/Foundation.h> | |
// clang -g -Wall -framework Foundation -o atomic atomic.m | |
// gcc -g -Wall -framework Foundation -o atomic atomic.m | |
@interface Blah : NSObject | |
@property (assign, NS_NONATOMIC_IOSONLY) NSInteger frobnozzle; | |
@property (assign, ) NSInteger commaAtEnd; | |
// @property (, assign) NSInteger commaAtBeginning; // Syntax error | |
@property (atomic, assign) NSInteger blah; // complains in gcc |
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
#import <Foundation/Foundation.h> | |
// clang -g -Weverything -framework Foundation -o count count.m | |
@interface CountTest : NSObject | |
- (NSUInteger) count; // notice not a @property | |
@end |
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
#import <Foundation/Foundation.h> | |
#import <mach/mach_time.h> // for mach_absolute_time() and friends | |
// clang -g -fobjc-arc -Weverything -Wno-unused-parameter -framework Foundation -o iteration iteration.m | |
// Run this by passing arguments on the command line. Run without any | |
// arguments to see the supported flags. Each time a flag is used causes | |
// that test to be run and timed, with the time (in seconds) output when | |
// it finishes. Be careful not to do anything else on your machine (such | |
// as surfing Redding while getting bored looking at the terminal) otherwise |
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
#import <stdio.h> | |
// clang -g -Wall -o old-days old-days.m | |
typedef struct Rect { | |
int x, y, w, h; | |
} Rect; | |
typedef enum { |
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
#import <Foundation/Foundation.h> | |
// clang -g -Wall -framework Foundation -o someObject someObject.m | |
@interface SomeObject : NSObject | |
- (void) doSome: (id) stuff for: (id) reasons; | |
@end // SomeObject |