Re: Some advice requested on debugging a difficult problem. iOS.

Quincey Morris

Yes, unfortunately, that is the correct behavior. This is described here:

under “Search Pattern for the Basic Getter”, step 4:

"If no simple accessor method or group of collection access methods is found, and if the receiver's class method accessInstanceVariablesDirectly returns YES, search for an instance variable named _<key>, _is<Key>, <key>, or is<Key>, in that order. If found, directly obtain the value of the instance variable and proceed to step 5."

In other words, as long as the underlying instance variable is “_rootURLMap”, using a method named “rootURLMap” will find it.

I strongly recommend overriding class method “accessInstanceVariables” to return NO in *all* data model classes in all production apps. There’s been no valid use case for the legacy behavior of step 4 for 10 years or more, except for compatibility with older code that might have accidentally relied on it.

On Mar 26, 2019, at 09:09 , Alex Zavatone via Groups.Io <zav@...> wrote:

I just replicated this in a sample and ran a short test to see what the results are.  

@interface MyObject : NSObject

@property(strong, nonatomic, readwrite,getter=getRootAPIData) NSDictionary *rootUrlMap;


@implementation MyObject

- (id)init {
    if (self == [super init]) {
        _rootUrlMap = [NSDictionary dictionaryWithObjectsAndKeys:@"Hi",@"myKey", nil];
    return self;


    MyObject *myObject = [MyObject new];
    NSLog(@"%@", myObject.rootUrlMap);
    NSLog(@"%@", myObject.getRootAPIData);
    NSLog(@"%@", [myObject getRootAPIData]);

2019-03-26 11:01:30.116353-0500 Test[80252:7074112] {
    myKey = Hi;
2019-03-26 11:01:30.116528-0500 Test[80252:7074112] {
    myKey = Hi;
2019-03-26 11:01:30.116654-0500 Test[80252:7074112] {
    myKey = Hi;

So, the getter and the property name both allow accessing the property.

But should we expect it to if the getter has been redefined?

Join to automatically receive all group messages.