Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Add option to preserve mutability when setting value to NSMutableArray properties #25

Merged
merged 2 commits into from
Dec 11, 2015

Conversation

dstranz
Copy link
Contributor

@dstranz dstranz commented Dec 1, 2015

How to replicate problem?

  1. Create Motis object with NSMutableArray property
  2. Set values with mts_setValuesForKeysWithDictionary
  3. In mts_validateAutomaticallyValue:toClass:forKey: array is parsed in first lines, in if ([*ioValue isKindOfClass:typeClass]) statement with return YES at the end.

Now arrays are not parsed at the beginning, they go to the existing if/else statement where mutability is properly checked.

@dstranz
Copy link
Contributor Author

dstranz commented Dec 8, 2015

@vilanovi what do you think about this fix? :)

@vilanovi
Copy link
Contributor

Hello, sorry for the delay. I'll try to give it a look before this Friday.

@vilanovi
Copy link
Contributor

I've been reviewing your changes and I do agree on them, mostly. Let me explain myself:

  • Line 1033: ok. We will return YES directly if the *ioValue class and classType matches and the class type of *ioValue is not an NSArray. In that case we will execute the validation.
  • Line 1157: Here I do not agree. Mainly, I don't want to "return *ioValue != nil" as I need to check the exact type of the classArray and be sure that it is something known. Otherwise we risk that Motis returns an instnace of NSArray for something that it is not. Therefore, I'd rather add another "else if" statement and include the NSArray as the last type check.

I'll merge your changes and then apply mine on top (this way you can pull).

Thanks,

vilanovi added a commit that referenced this pull request Dec 11, 2015
Add option to preserve mutability when setting value to NSMutableArray properties
@vilanovi vilanovi merged commit 8f49e97 into mobilejazz:master Dec 11, 2015
@dstranz
Copy link
Contributor Author

dstranz commented Dec 11, 2015

Yes, you are right. There should be another else if to check if typeClass is NSArray.

Thank you!

@vilanovi
Copy link
Contributor

I've also added some tests to validate it (also with sets, ordered sets, mutable sets and mutable ordered sets).

New version 1.4.3 already pushed to cocoa pods.

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants