Skip to content

Instantly share code, notes, and snippets.

@matzew
Created October 30, 2012 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matzew/3979172 to your computer and use it in GitHub Desktop.
Save matzew/3979172 to your computer and use it in GitHub Desktop.
ARC vs none ARC

ARC:

SomeHacks.h

@interface SomeHacks : NSObject

@end

SomeHacks.m

@implementation SomeHacks

-(void) foo {
    NSLog(@"\n\nFOOOOOOOO\n\n");
}

@end

Caller:

SomeHacks* hacks = [[SomeHacks alloc] init];

[hacks foo];

COMPILE ERROR: ARC Semantic Issue: No visible @interface for 'SomeHacks' declares the selector 'foo'

No ARC:

SomeHacks.h

@interface SomeHacks : NSObject

@end

SomeHacks.m

@implementation SomeHacks

-(void) foo {
    NSLog(@"\n\nFOOOOOOOO\n\n");
}

@end

Caller:

SomeHacks* hacks = [[SomeHacks alloc] init];

[hacks foo];

WARNING this code compiles and invokes the 'foo' - Generates (expected) warning "Instance method '-foo' not found (return type defaults to 'id')"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment