Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of the console message: "snarfed from ivar layout..."?

I have a console message that appears to be triggered by apparently unrelated events.

The message states:

snarfed from ivar layout: [propertyName] = [constantString]

Where [propertyName] is the name of a property to which I set the value of a string constant [constantString].

What causes this message and what does it means?

like image 692
Fabio Avatar asked May 24 '11 16:05

Fabio


People also ask

What is the use of console warning?

Used to log error message to the console. Useful in testing of code. By default the error message will be highlighted with red color. Used to log warning message to the console. By default the warning message will be highlighted with yellow color. console.warn ('This is a warning.');

What is the use of the color red in the console?

Used to log error message to the console. Useful in testing of code. By default the error message will be highlighted with red color. Used to log warning message to the console. By default the warning message will be highlighted with yellow color.

What is the purpose of the console name in the console?

NAME specifies the console name that uniquely identifies the console. The console name is required on all consoles except for the system console. Any values you specify for the NAME parameter (names identifying the console) must be unique across the sysplex.

What does the Lu keyword DO in MVS?

The LU keyword is optional, but may only be specified with DEVNUM (SMCS). If LU is specified, the console can only be activated at that LU, and no other console can be activated with that LU. For more information, see the z/OS MVS Planning: Operations information.


1 Answers

I also ran into this issue recently. I was able to fix my specific issue, but I don't think that is exactly what the questioners are running into, since my issue was only being exposed in VoiceOver mode. As such, I'll offer thoughts on what I think is generally occurring and then I'll speak to my specific issue.

As for the general issue, I think that the Apple Framework is deciding to look through all of the ivars of a particular class in order to extract some information that it wants, but that is not provided by other parts of the UI element. This seems a little bizarre to me, but that is what I encountered.

So, to continue with the general case, and in answer to the initial question. If you're like me, then your property name is probably the same as your ivar. Try explicitly defining a getter method for that property. Then, set a breakpoint within that getter if you will be returning a non-nil value. Look at the stacktrace and that should tell you which piece of the apple frameworks is deciding to loop through your ivar layout in order to get the information it wants. (If you're not using the the same name for your property and ivar, then just define a property and getter with the ivar name and do the same thing with the breakpoint.)

My specific case was for a Custom Table Cell (like one of the commenters). In that cell,I had a property that was the same name as its ivar. I also had an explicitly defined getter for that property. I also referenced that custom table cell from the Nib file. So, it looked something like this:

class CustomTableViewCell:UITableViewCell
{
    NSString *s ; 
} 
@property(nonatomic,retain) NSString *s ; 

and in the implementation:

@synthesize s ; 
-(NSString *)s 
{
    if( !s ) 
        return self.reuseIdentifer ; 
    return s ; 
}

I put a breakpoint in the return self.reuseIdentifier line,and that showed me a stacktrace from the Accessibility functions. The stacktrace showed my method being called by an Apple internal method that was looping through all of my ivars looking for something to use as the accessibilityLabel for my table cell. The name of the selector is '_accessibilityRetrieveTableViewIvarsText'.

To make matter worse, in my case, this was not just a debugger issue, it was messing up my Accessibility interface by using the wrong thing as the accessibilityLabel.

I came up with 3 fixes for my specific problem:

1) I added a value for the accessibilityLabel for the table cell inside the Nib. This satisfied the Apple framework to the point where it did not go searching through my ivars. This was not the solution I went with, however, because I did not want a static accessibility label.

2) I subclassed my CustomTableViewCell with an empty implementation and interface, and I used that as my Table cell class inside the Nib. This solved the problem because the Apple Framework looped through that class's ivars, of which there were none, and there weren't any values to 'snarf'. I did not use that solution either, but it might be the best one because it keeps Apple's frameworks from inspecting my ivars.

3) The solution I decided on was to make my ivar private and to define the property with a different name. That seems to be the standard way that a lot of folks use properties. This is what it looks like:

class CustomTableViewCell:UITableViewCell
{
    @private
        NSString *_s ; 
}  
@property(nonatomic,retain) NSString *s ; 

and in the implementation:

@synthesize s = _s ; 
-(NSString *)s  
{
    if( !_s ) 
        return self.reuseIdentifer ; 
    return _s ; 
}

This fixed the problem because nil is returned when Apple inspects the ivar, and, thus, nothing is 'snarfed'. I'm still not sure whether this or #2 is more appropriate.

like image 53
Rich Waters Avatar answered Sep 30 '22 07:09

Rich Waters