Post

Replies

Boosts

Views

Activity

What is the best way to save data on the device?
In swift UIKit I want the best way to save data on the device So that the user can refer to it later Like notes, photos, and videos Is she on Userdefaults or Core Data Or is there a better way to use it? I am a beginner and you may not know a few things Because I worked to save notes, photos and videos on the Core Data, and I encountered problems, I could not view the video I hope to answer for anyone who has any useful information, and I will be thankful to you
2
0
1.2k
Jan ’22
Play video from core data
in swift UIKit I have a video from my camera roll I store it in core data But when I restore it and when I try to turn it on, it doesn't work Is my idea correct? I can store and display the video use PHPickerViewController result.itemProvider.loadFileRepresentation(forTypeIdentifier: UTType.movie.identifier) { url, err in                 do {                     if let urls = url {                                                  let localURL = FileManager.default.temporaryDirectory.appendingPathComponent(urls.lastPathComponent)                         try? FileManager.default.removeItem(at: localURL)                         try FileManager.default.copyItem(at: urls, to: localURL)                         DispatchQueue.main.sync {                                                          coreDateHelperMedia().storeMedia(urlImg: UIImage.init(), videoURL: localURL, types: "video")                             self.collection.reloadData()                         }                     }                 } catch let error {                     print("Error",error)                 }             } Here I present it let dataUrl = arrS1[indexPath.row]                 let urlvideo = dataUrl.videoSection?.absoluteString                                  guard let url = URL(string: urlvideo!) else {return}                 let player = AVPlayer(url: URL(fileURLWithPath:url.path))                 playerController = AVPlayerViewController()                 playerController.player = player                 playerController.allowsPictureInPicturePlayback = true                 playerController.delegate = self                 present(playerController, animated: true) {                     player.play() I've been sitting for a week and I'm doing everything I can, but I don't understand what's wrong Although without data storage, it works fine
0
0
458
Jan ’22
Transfer data on return
I have 2 views ViewController A and ViewController B I have data in ViewController A in tableview I display the data for each cell in the ViewController B in ViewController B i have TextFiled and TextView Are the same ViewController B I am modifying the data But when I edit, I have a save button in which I save the new data After saving, I want to go back to ViewController A through the . button Back item But the back button does not bring back the tableview functions again I tried viewwillappear But it executes the function twice before and after Is there a function that we only call on the back button?
3
0
438
Jan ’22
Put the video in the collection from PHPickerViewController
in swift UIKit I am trying to display a group of photos and videos through PHPicker The pictures appear with me, but the video shows a white picture I don't know where the error is, if someone can explain to me     func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) {         dismiss(animated: true, completion: nil)         //For Image         for result in results {             result.itemProvider.loadObject(ofClass: UIImage.self) { image, error in                 if let image = image as? UIImage {                     DispatchQueue.main.async {                         self.arrS1.append(addCatogrey(imageSection: image))                         self.SelectImage = image                         self.collection.reloadData()                     }                 }             }             //For Video             result.itemProvider.loadItem(forTypeIdentifier: UTType.movie.identifier, options: nil) { video, error in                 if let video = video as? URL {                     DispatchQueue.main.async {                         self.arrS1.append(addCatogrey(videoSection: video))                         self.SelectVideo = video                         self.collection.reloadData()                     }                 }             }         }     } My Cell class CVCell: UICollectionViewCell {     @IBOutlet weak var imgMenu: UIImageView!     @IBOutlet weak var textMenu: UILabel!     var playerController = AVPlayerViewController()     var addModel : addCatogrey! {         didSet {             self.textMenu.text = addModel.nameCatog             self.imgMenu.image = addModel.imageSection         }     } } My Model     var nameCatog : String?     var imageSection : UIImage?     var videoSection : URL? }
0
0
347
Jan ’22