We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This code causes a memory leak. If I use JSON decoder then there is no memory leak. Any idea how to fix this?
import Foundation import CSV typealias TestCodable = Test & Codable protocol Test { func baz() } struct Product1:TestCodable { var title:String var price:Int var quantity:Int func baz() { print(title) } } let csv = """ title,price,quantity Nike,10,1 Nike1,11,1 Nike2,12,1 Nike3,13,1 Nike4,13,1 Nike5,13,1 Nike6,13,1 """ let json = """ { "title": "Nike", "price": 10, "quantity": 1 } """ let data = json.data(using: .utf8)! var arrayProduct: [Test] = [] let reader = try CSVReader(string: csv, hasHeaderRow: true) let decoder = CSVRowDecoder() while reader.next() != nil { // let product: Product1 = try! JSONDecoder().decode(Product1.self, from: data) let product = try! decoder.decode(Product1.self, from: reader) arrayProduct.append(product) print("\(product)") sleep(4) }
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
swift 5 solved the problem
No branches or pull requests
This code causes a memory leak.
If I use JSON decoder then there is no memory leak.
Any idea how to fix this?
The text was updated successfully, but these errors were encountered: