how can I create and access share app group document directory?

Deadly 提交于 2019-12-02 14:12:45

Solved

  let fileManager = FileManager.default
                                        let url = fileManager.containerURL(forSecurityApplicationGroupIdentifier: "group.companyname.appname")?.appendingPathComponent("logo.png")

                                        // store image in group container
                                        if !fileManager.fileExists(atPath: url!.path) {

                                            let image =  UIImage(data: data)
                                            let imageData : Data = UIImagePNGRepresentation(image!) as! Data
                                            fileManager.createFile(atPath: url!.path as String, contents: imageData, attributes: nil)
                                        }

//ACCESS THIS or get store image 
 let Image1 = UIImage(contentsOfFile: (url?.path)!)! 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!