How to save an array to .plist in the App's mainBundle in swift

后端 未结 2 1104
梦谈多话
梦谈多话 2020-12-22 09:42

How I can save array to .plist with array type?

I try this, but is not working

    let path = NSBundle.mainBundle().pathForResource(\"Setting\", ofTy         


        
2条回答
  •  悲&欢浪女
    2020-12-22 10:21

    You can't write to the main bundle in iOS, everything inside your Apps bundle is read only.

    [The App's bundle ] directory contains the app and all of its resources. You cannot write to this directory. To prevent tampering, the bundle directory is signed at installation time. Writing to this directory changes the signature and prevents your app from launching. You can, however, gain read-only access to any resources stored in the apps bundle.

    Consider reading the file system programming guide and then persist your plist to the correct location. Preferably the Documents directory or the Library directory. Up to you.

提交回复
热议问题