Comments (6)
Hi @mikkelharris, I haven't seen this issue before. It might have something to do with subclasses of NSManagedObject. Would you be able to post the code that you're trying to get working in here? It could also be a problem with your setup as well. Either way, this should be something that can work so let's figure it out.
from argo.
Thanks for the help @tonyd256
I think it has something to do with how Argo is interacting with my NSManagedObject subclass. I was able to copy your example from the README and it built fine. Here’s what I’m working with:
import Foundation
import CoreData
import Argo
import Runes
class Program: NSManagedObject {
@NSManaged var hollandCodes: String
@NSManaged var programGroupID: NSNumber
@NSManaged var summary: String
@NSManaged var url: String
@NSManaged var programGroup: ProgramGroup
}
extension Program: JSONDecodable {
class func create(hollandCodes:String)(programGroupID:NSNumber)(summary:String)(url:String) -> Program{
return Program(hollandCodes:hollandCodes, programGroupID:programGroupID, summary:summary, url:url)
}
class func decode(j:JSONValue) -> Program? {
return Program.create
<^> j <| "HollandCodes"
<*> j <| "ProGroupID"
<*> j <| "Description"
<*> j <| "URL"
}
}
from argo.
We've seen issues with class types that aren't final. The workaround is to set the DecodedType
of the JSONDecodable
protocol. Check out the tests in the Model folder NSURL.swift
. Try setting this in the extension on Program
:
typealias DecodedType = Program
from argo.
You'll also need to make sure NSNumber
conforms to JSONDecodable
. I haven't done this since I've only considered Int
. You can take a look at how Argo does this in Argo/Globals/JSON.swift. And finally, it looks like you're missing the ProgramGroup
variable in your create
function and in the init inside. Then you'll need to make ProgramGroup
JSONDecodable
and add it to the bottom of the decode
function.
from argo.
My issue was in the fact that I was using an NSNumber as one of the argument types in my create function. Instead of throwing an error, Xcode would just hang.
After trying to replicate my situation from scratch, I started receiving an error, "Type 'NSNumber' does not conform to protocol 'JSONDecodable'" for my new test objects.
However when I went back to my original object it would just hang Xcode. Not sure why this is the case but at least I've discovered why it was not working for me
from argo.
Argo is pushing the limits of the compiler. If types don't match up properly it usually just hangs as you've been seeing. If you experience it again I would just make sure that all your types that you try to parse from the JSON conform to JSONDecodable, that you've included all the parameters in your create function and in your decode function, and that you've made sure to use the correct Argo operator for arrays and optionals.
Closing this now.
from argo.
Related Issues (20)
- error: no such module 'Runes' HOT 7
- Problem with Decodable on xcode 9 HOT 3
- RFC: Renaming the Decodable protocol
- How to decode a "Dictionary" to "[Model]"? HOT 3
- Parse nested array failed HOT 5
- Parse nested model fails when adding a specific key HOT 2
- How to decode dynamic keys HOT 2
- RFC: Renaming (or removing) the `<|` family of operators HOT 5
- Decode type 'Any' HOT 2
- RFC: Make Swift.Decodable conform to Argo.Decodable in Swift 4.1 HOT 4
- Convert all wrong type return JSON to specific type HOT 6
- Decoding the same object with different keys HOT 6
- How to parse an empty dictionary object in Argo HOT 1
- [Question] Array decoding HOT 4
- Using pure can't compile using Swift 3 HOT 2
- Decodable' is ambiguous for type lookup in this context (Swift4) HOT 1
- Parsing a json array with strings and objects intermixed HOT 2
- Xcode 11.0 compatibility issue HOT 3
- Xcode 11.2.1 Binary operator '<^>' cannot be applied to operands of type HOT 7
- Upgrade to version 5.0.0 blocked due to Ogra library HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from argo.