Objective-C class properties don't work as expected

Originator:nikolai.ruhe
Number:rdar://28694926 Date Originated:10-Oct-2016 05:44 PM
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 10, Xcode 8.1 beta 2
Classification:Other Reproducible:Always
 
Summary:
Class properties are expected to be usable with dot notation. When using a custom getter name this does not work as expected.

Steps to Reproduce:
Given the following declaration:

    @interface Foo : NSObject
    @property (class, readonly, getter=sharedInstance) Foo *shared;
    @end

... one expects the following to compile:

    Foo *foo = Foo.shared;
    
... yet the compiler issues the following error:

    property 'shared' not found on object of type 'Foo'

After changing the code to:

    Foo *foo = Foo.sharedInstance;

... the error goes away.

This is not the expected behavior and not in line with instance properties.

Expected Results:
`Foo.shared` should compile without errors.

Actual Results:
`Foo.shared` does not compile.

Comments

Why would you expect this to work? You told the compiler that the getter is called "sharedInstance", not "shared".

By jordanbondo at Oct. 13, 2016, 5:02 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!