Created
February 15, 2014 05:29
-
-
Save rgoulter/9014947 to your computer and use it in GitHub Desktop.
ObjC Using Categories to Modularise Long File
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 "foo.h" | |
@interface Foo (foobar) | |
- (void) foo; | |
- (void) bar; | |
@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 "foo.h" | |
@interface Foo (spameggs) | |
- (void) spam; | |
- (void) eggs; | |
@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 <stdio.h> | |
#import <Foundation/Foundation.h> | |
@interface Foo : NSObject | |
- (void)foo; | |
- (void)bar; | |
- (void)spam; | |
- (void)eggs; | |
@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 "foo.h" | |
@implementation Foo | |
- (void) foo { | |
printf("foo\n"); | |
} | |
- (void) bar { | |
printf("bar\n"); | |
} | |
- (void) spam { | |
printf("spam\n"); | |
} | |
- (void) eggs { | |
printf("eggs\n"); | |
} | |
@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 <stdio.h> | |
#import "foo.h" | |
int main(int argc, char **argv) { | |
Foo *f = [Foo new]; | |
[f foo]; | |
[f bar]; | |
[f spam]; | |
[f eggs]; | |
return 0; | |
} |
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 "foo.h" | |
@implementation Foo (foobar) | |
- (void) foo { | |
printf("foo\n"); | |
} | |
- (void) bar { | |
printf("bar\n"); | |
} | |
@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 "foo.h" | |
@implementation Foo (spameggs) | |
- (void) spam { | |
printf("spam\n"); | |
} | |
- (void) eggs { | |
printf("eggs\n"); | |
} | |
@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 "foo.h" | |
#import "foo+foobar.h" | |
#import "foo+spameggs.h" | |
@implementation Foo | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To compile with the "long" file, of course:
To compile with the "short" files:
With the latter, however, since
shortfoo.m
is an incomplete implementation (we leave methods to categories), and because some methods of the primary class are implemented by categories, we get two warnings for each method: incomplete-implementation and objc-protocol-method-implementation.