nicklockwood / FXForms

[DEPRECATED]
Other
2.93k stars 339 forks source link

Fix clang errors #378

Open davidrothera opened 9 years ago

davidrothera commented 9 years ago

Changes

Fixes #365

Testing

nicklockwood commented 9 years ago

That doesn't make a whole lot of sense. self.fields is functionally equivalent to [self fields]. Can you explain what effect you believe this change had on the behavior?

davidrothera commented 9 years ago

The basis behind my change was that calling self.fields accesses the instance variable which could be nil however using the [self fields] method[1] will instantiate a non-existing instance variable.

[1] https://github.com/davidrothera/FXForms/blob/develop/FXForms/FXForms.m#L1732

nicklockwood commented 9 years ago

But self.fields doesn't access the instance variable. It calls the - (NSMutableArray *)fields method. To access the instance variable, you'd have to write self->_fields.

Try putting a breakpoint inside - (NSMutableArray *)fields and you can verify that it's called when you access self.fields.

I think perhaps the issue that you're referring to is "Argument to 'NSMutableArray' method 'addObject;:' cannot be nil"? In which case the issue it's complaining about is that the field value being added to the array is nil, not the array itself.

I'll fix this in the next update.

davidrothera commented 9 years ago

Yeah I think you are right, its strange though as making the change in the PR resolved the clang error and retained all functionality.

nicklockwood commented 9 years ago

Hmm, I can't actually replicate a clang warning on the line you fixed. The warning I'm seeing is on the line a few below that: [self.fields addObject:field]

davidrothera commented 9 years ago

Yes, the error was on that line and the change I made resolved that one lower down.

nicklockwood commented 9 years ago

I think maybe the change above just confused the analyzer so that it couldn't parse the logic below anymore ¯(ツ)

davidrothera commented 9 years ago

Quite possibly, clang isn't the smartest ;)