XIBRuntimeAttributeMismatch should check instance variables

Issue #70 closed
Ignazio Calo' created an issue

This error message doesn't take in account that the property can be defined on a superclass.

Step to replicate: 1. Create a class "ParentClass" subclass of "UIView" and add a property "someProperty". 2. Create a subclass of "ParentClass" called "ChildClass" 3. On a xib file or storyboard add a view and specify the class type "ChildClass" 4. Define a runtime attribute with name "someProperty" 5. Run Faux Pas.

Comments (6)

  1. Ali Rantakari repo owner

    Thanks for reporting this.

    This rule should indeed be checking properties in superclasses in the manner described, but it's possible that a bug is preventing this feature from working correctly.

    I have been unable to reproduce this issue — can you please provide a small Xcode project that demonstrates the false positive?

  2. Ali Rantakari repo owner

    Thanks for the sample project.

    It does however look like the diagnostic is correct in this case — ParentClass has a property called keyProperty while Main.storyboard sets the string FOOBAR with the key path keyPath.

    If you run the sample project with the debugger attached, you'll see this in the Xcode console:

    2015-08-18 20:13:09.652 SampleProject[15647:463754] Failed to set (keyPath) user
    defined inspected property on (ChildClass): [<ChildClass 0x7fc0c3725e20> setValue:forUndefinedKey:]:
    this class is not key value coding-compliant for the key keyPath.
    
  3. Ignazio Calo' reporter

    I'm sorry, there was one error on that project. The error was the name of the runtime attribute, it should be keyProperty as defined on the ParentClass, keyPath doesn't exist at all!

    Fixing the project I found also a more specific case that cause the "bug". In particularly FauxPas checks for properties that are defined on the class or on the superclass, but -probably- not for the ivars.

    Now the ParentClass has an ivar keyProperty, a subclass called ChildClass is used on storyboard and a keyProperty is configured as a runtime attribute. In this case FauxPax generate the warning XIBRuntimeAttributeMismatch

    Here the link with the second version of the project. https://dl.dropboxusercontent.com/u/792862/SampleProject%20v2.zip

  4. Log in to comment