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

前端 未结 1 1557
一向
一向 2021-01-22 03:07

i am using custom keyboard extension then download keyboard theme from server and save in to app document directory but app document directory can not access in custom keyboard

相关标签:
1条回答
  • 2021-01-22 04:00

    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)!)! 
    
    0 讨论(0)
提交回复
热议问题