• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Private Methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Private Methods
      • From: Quincey Morris <email@hidden>
References: 
 >Private Methods (From: Richard Charles <email@hidden>)
 >Re: Private Methods (From: Sean McBride <email@hidden>)
 >Re: Private Methods (From: Richard Charles <email@hidden>)
 >Re: Private Methods (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Private Methods
  • Next by Date: Re: Thread-safe singleton with lazy initialisation
  • Previous by thread: Re: Private Methods
  • Next by thread: Re: Private Methods
  • Index(es):
    • Date
    • Thread