New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initializing nested arrays? #183
Comments
Hi, I was away for a long weekend... For your first question: NSObject is good enough in a lot of cases. If you do want 99% of the functionality, then you should extend it with the EVReflectable protocol. If you want to have all functionality, then it should be an EVObject. And then your other question... Is your json structured like this? I will have a look how that should work. |
Yes that is correct on the structure and all objects nested are a direct subclass of EVObject. I thought it may have been my fault so I tried the same structure but with simple NSNumbers as the data. Same result. |
This code does work:
|
And this also works:
|
I'm so sorry. How dumb of me. Totally forgot to mention. My errors came when trying to iterate through the array. Or even pulling a object via index. array[0][0][0] |
Heres the actual error.
This comes when looping as follows. It only crashes when looping through the objects themselves.
This is what I get rather than my class objects when I breakpoint and inspect it. |
I will have a look at it this weekend |
Get a chance to look at it? Anyway I can help? If it seems like its going to be a little while before you get to it, I could just make a property converter. I'm sure you're a busy man. I can imagine what you do professionally if you create things like this on the side lol. |
I have confirmed it's a bug. It sets the value with the dictionary array. Strange enough you can just print it. That's why I assumed it was fixed. This week I was passed out with the flue, so I did not have a chance to see if there is a fix. I do know this one will be hard to fix. So don't expect a fix within 2 weeks. A property converter probably is the fastest solution. But still I do want this to be fixed. |
Awesome! Thanks for letting me know! I had no doubt you would wanna get it fixed. You make this repository by far one of the most responsive I have ever seen when it comes to issues. Hope you are feeling better! When it comes to the property converter. I assume it should be able to be to be converted into a [[[NSDictionary]]]? I think that's what I saw when I inspected it upon crash. |
I'm feeling better, thanks. I already found out where I have to add the support for nested arrays. It's in the dictionaryAndArrayConversion function. I see dictionaryAndArrayConversion I have enough info to fix it there. |
I will push a fix for this issue later today. It's working.. I only have to create a couple of extra unit tests... |
Its pushed as version 4.11.0 |
fatal error: NSArray element failed to match the Swift Array Element type @evermeer Still have an issue when trying to enumerate. Haven't tried accessing individual objects in my application like you have in your test in a while. Not sure if I mentioned it but these EVObjects inside the nested arrays contain other EVObjects. Haha even some of those objects inside those objects have EVObjects. Not sure if that can contribute. Haha we kinda used this kick ass framework as the backbone to initialize our entire model. Not a huge deal to get this done though. I turned my json data into [[[NSDictionary]]] and just looped and initialized individual arrays of EVObjects. That works for now. Again though, I appreciate your hard work. |
I tried pulling an individual object myData.data[0][0][0] and no luck When I crash and inspect an individual object post-crash during the array loop I see
When I look at its sub objects I see this.
Not sure if any of this helps but thought id mention it. |
I am trying to find a way to initialize an array with nested arrays without having to initialize a class to do so.
I tried
let myArrays = [[[MyObject]]](json: myDataString)
But of course I got an error saying that [[MyObject]] was not a subclass of NSObject. (Subquestion...using this method it doesn't have to be a EVObject?)
I also get the same error doing it through classes.
also did
I get the same error every time. Not sure what to do to get this to work without making a property converter. Even if I went that route Im not sure what I would convert this into. Maybe a
and try to loop through each array till I have my array of dictionaries and then convert that?
The text was updated successfully, but these errors were encountered: