-
Notifications
You must be signed in to change notification settings - Fork 126
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
write_to,会覆盖原来的对象 #14
Comments
??你是说覆盖原来的文件内容?? |
是的
| |
sir wang
|
|
邮箱:biancheng347@163.com
|
Signature is customized by Netease Mail Master
在2019年08月23日 12:19,M了个J 写道:
??你是说覆盖原来的文件内容??
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
let file: string = "......./test.data" let p2 = person() 应该是[p1,p2],但是只有p2 |
这是合理的 |
let p1 = Person()
var ps = [p1]
write(ps, to: file)
let p2 = Person()
ps.append(p2)
write(ps, to: file)
let p1 = Person()
write([p1], to: file)
let p2 = Person()
var ps = read([Person].self, from: file)
ps.append(p2)
write(ps, to: file) |
我建议可以提供一个接口 write(addOrUpdate: p2,to: file) ,内部代码是 var ps = read([Person].self, from: file) 上层代码不管这些细节 |
谢谢建议,下个版本考虑下 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
write_to,会覆盖原来的对象
The text was updated successfully, but these errors were encountered: