Skip to content
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

Just an idea to help you extend Codextended #6

Closed
wants to merge 1 commit into from
Closed

Just an idea to help you extend Codextended #6

wants to merge 1 commit into from

Conversation

evermeer
Copy link

code comes directly from https://github.com/evermeer/Stuff#codable
Feel free to use any of it in Codextended.
it's not formatted conform your coding style and not tested for incompatibilities with your code.

Here is a short list of what you could do with this.

let json = yourEncodableObjectInstance.toJsonString()
let data = yourEncodableObjectInstance.toJsonData()
let newObject = try? YourCodableObject(json: json)
let newObject2 = try? YourCodableObject(data: data)
let objectArray = try? [YourCodableObject](json: json)
let objectArray2 = try? [YourCodableObject](data: data)
let newJson = objectArray.toJsonString()
let innerObject = try? TestCodable(json: "{"user":{"id":1,"naam":"Edwin"}}", keyPath: "user")
try initialObject.saveToDocuments("myFile.dat")
let readObject = try? TestCodable(fileNameInDocuments: "myFile.dat")
try objectArray.saveToDocuments("myFile2.dat")
let objectArray3 = try? TestCodable

code comes directly from https://github.com/evermeer/Stuff#codable
Feel free to use any of it in Codextended.
it's not formatted conform your coding style and not tested for incompatibilities with your code.

Here is a short list of what you could do with this.

let json = yourEncodableObjectInstance.toJsonString()
let data = yourEncodableObjectInstance.toJsonData()
let newObject = try? YourCodableObject(json: json)
let newObject2 = try? YourCodableObject(data: data)
let objectArray = try? [YourCodableObject](json: json)
let objectArray2 = try? [YourCodableObject](data: data)
let newJson = objectArray.toJsonString()
let innerObject = try? TestCodable(json: "{\"user\":{\"id\":1,\"naam\":\"Edwin\"}}", keyPath: "user")
try initialObject.saveToDocuments("myFile.dat")
let readObject = try? TestCodable(fileNameInDocuments: "myFile.dat")
try objectArray.saveToDocuments("myFile2.dat")
let objectArray3 = try? [TestCodable](fileNameInDocuments: "myFile2.dat")
@JohnSundell
Copy link
Owner

Hi @evermeer! Thanks for the offer of using this code, but I'm not interested in extending Codextended's scope to include that new functionality, at least not right now. For now I want to keep it as simple as possible, and only act as a lightweight set of extensions on top of Codable. So thanks a lot, but I'll close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants