Re: Private Methods
Re: Private Methods
- Subject: Re: Private Methods
- From: Charles Srstka <email@hidden>
- Date: Tue, 18 Aug 2015 14:07:58 -0500
> On Aug 18, 2015, at 12:20 PM, Jens Alfke <email@hidden> wrote:
>
> But would Swift have caught this issue, since the CALayer.context property isn’t visible in headers at all, only in the compiled code?
Jens Alfke, of mooseyard.com <http://mooseyard.com/>, has presented us with a poser. We do not know which bush the private method is behind. But we can soon find out.
MyBaseClass.h in framework:
#import <Foundation/Foundation.h>
@interface MyBaseClass : NSObject
- (void)foo;
@end
MyBaseClass.m in framework:
#import "MyBaseClass.h"
@implementation MyBaseClass
- (void)foo {
fprintf(stderr, “BOOM!\n");
}
@end
App:
import MyFramework
class MyClass: MyBaseClass {
func bar() {
print(“BLEAH!")
}
}
let obj = MyClass()
obj.foo()
Output:
BOOM!
New MyBaseClass.m:
#import "MyBaseClass.h"
@implementation MyBaseClass
- (void)foo {
fprintf(stderr, "BOOM!\n");
[self bar];
}
- (void)bar {
fprintf(stderr, "Bar called in framework\n");
}
@end
Output without recompiling the app:
BOOM!
BLEAH!
Output after recompiling the app:
No compiler errors, then:
BOOM!
BLEAH!
Yes, it was the middle one. (And also the one on the right.)
Charles
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden