Skip to content

Instantly share code, notes, and snippets.

#ifdef DEBUG
# define LOG(...) NSLog(__VA_ARGS__)
# define LOG_METHOD NSLog(@"%s", __func__)
#else
# define LOG(...) ;
# define LOG_METHOD ;
#endif
switch (n) {
case 0 ... 3:
process(n);
break;
}
aClass* anObject=[[[anArray lastObject] retain] autorelease];
[anArray removeLastObject];
@interface Class : NSObject
{
}
@end
#import <Cocoa/Cocoa.h>
@interface Book : NSObject {
}
- (id)init;
- (void)dealloc;
@end
#import <Cocoa/Cocoa.h>
@interface Child : NSObject {
}
- (id)init;
- (void)dealloc;
@end
@implementation Child
- (id)init
{
#import <Cocoa/Cocoa.h>
int main(){
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString * string = [NSString stringWithString:@"Hello"];
NSLog(@"%@", string);
[pool release];
return 0;
}
#import <Cocoa/Cocoa.h>
@interface Hoge : NSObject {
}
- (id)init;
- (void)dealloc;
+ (Hoge*)hoge;
@end
@implementation Hoge
- (id)init
#import <Foundation/Foundation.h>
@interface Foo : NSObject
@end
@implementation Foo
- (void)dealloc {
NSLog(@"%s called", __func__);
[super dealloc];
}
#import <Foundation/Foundation.h>
@interface ReferenceCounter : NSObject {
id obj;
}
- (void)setObj:(id)_obj;
@end
@implementation ReferenceCounter
- (void)setObj:(id)_obj {