-
-
Save philosopherdog/6461536b99ef73a5c32a to your computer and use it in GitHub Desktop.
External Class Extension Mimics Protected Members
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
// | |
// ClassA.h | |
// TestHeader | |
// | |
// Created by steve on 2015-04-29. | |
// Copyright (c) 2015 steve. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface ClassA : NSObject | |
@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
// | |
// ClassA.m | |
// TestHeader | |
// | |
// Created by steve on 2015-04-29. | |
// Copyright (c) 2015 steve. All rights reserved. | |
// | |
#import "ClassA.h" | |
#import "Test.h" | |
@implementation ClassA | |
- (void)testWithMessage:(NSString *)message | |
{ | |
NSLog(@"%@", message); | |
} | |
@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
// | |
// ClassB.h | |
// TestHeader | |
// | |
// Created by steve on 2015-04-29. | |
// Copyright (c) 2015 steve. All rights reserved. | |
// | |
#import "ClassA.h" | |
@interface ClassB : ClassA | |
- (void)doIt; | |
@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
// | |
// ClassB.m | |
// TestHeader | |
// | |
// Created by steve on 2015-04-29. | |
// Copyright (c) 2015 steve. All rights reserved. | |
// | |
#import "ClassB.h" | |
#import "Test.h" | |
@implementation ClassB | |
- (void)doIt | |
{ | |
[self testWithMessage:@"My message"]; | |
} | |
@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
// | |
// main.m | |
// TestHeader | |
// | |
// Created by steve on 2015-04-29. | |
// Copyright (c) 2015 steve. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
#import "ClassB.h" | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
ClassB *classB = [ClassB new]; | |
[classB doIt]; | |
} | |
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
// | |
// Test.h | |
// TestHeader | |
// | |
// Created by steve on 2015-04-29. | |
// Copyright (c) 2015 steve. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface ClassA() | |
- (void)testWithMessage:(NSString *)message; | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment