Save data and images to FileManager in Xcode | Continued Learning #26

  Рет қаралды 32,156

Swiftful Thinking

Swiftful Thinking

Күн бұрын

Пікірлер: 78
@patrickphilipot
@patrickphilipot 3 жыл бұрын
I'm amazed at how simple it looks when clearly explained. You have a real talent for teaching.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Thanks for the comment Patrick! I'm very happy to help.
@tibettenballs4962
@tibettenballs4962 2 жыл бұрын
@@SwiftfulThinking he used to be a bully, and force me to eat dirt. now i eat bugs becuase its just a habit from him being a big ol meanie.
@Reallymellie
@Reallymellie 2 жыл бұрын
Hey Nick, Just want to thank you for all the content you make and the hard work you put in this videos. I am really thankful for that! The way how you teach is just amazing!
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
Thanks Melvin!
@nevemra5
@nevemra5 Жыл бұрын
Amazing as always. I love how detailed and slow you explain these complicated things. It really helps a lot.
@chrisstromberg6527
@chrisstromberg6527 Жыл бұрын
I really appreciate the "best practices" approach you take in citing Apple guidelines. Another excellent video!
@Josuegcp95
@Josuegcp95 Жыл бұрын
You're a great teacher, thank you for the content.
@hygisonbrandao9251
@hygisonbrandao9251 8 ай бұрын
You should be the one writing Apples documentation. I feel their docs are the worst. And you are the best ate making it simple and clear! Thanks
@balabon
@balabon 3 жыл бұрын
Awesome, better and better 👍
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Thank you as always Александр :)
@natgenesis5038
@natgenesis5038 2 жыл бұрын
You tought me SwiftUI from nothing to a pro thanks so much bro
@kenjyfukuda
@kenjyfukuda 3 жыл бұрын
Many thanks for your explanation in an organized and easy-to-follow manner. I'm enjoying your series of video tutorials "SwiftUI Continued Learning."
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Thanks for watching Kenji :)
@Nunny25
@Nunny25 3 жыл бұрын
Uff, long video, BUT very useful as always and FM is clear for me now. Thanks Nick.
@bingl172
@bingl172 3 жыл бұрын
Thank you! This is such a helpful tutorial. Super clear.
@frydaydeep6674
@frydaydeep6674 2 жыл бұрын
37:40: vm = Localmanager.instance() poped up, code changed and I didn't see you covered it? Captain Nick
@frydaydeep6674
@frydaydeep6674 2 жыл бұрын
what a clown i am : I used state var instead of @StateObject and infoMessage just won't show and no bug report from compiler
@rivforest2395
@rivforest2395 11 ай бұрын
simple, logical, easy to understand and follow. thank you for making this. How can you make the folder available to sync to the iCloud?
@kavinda_dilshan_paramsoodi
@kavinda_dilshan_paramsoodi 3 жыл бұрын
Good work Nic. learned a lot. long video doesn't bother us at all because we wanna learn it properly. so itz okay. keep up the good work.❤️
@maciusessa
@maciusessa 2 жыл бұрын
great vid as always
@readmoreapp
@readmoreapp 2 жыл бұрын
Great explaination. Love from India
@mintuz
@mintuz 3 жыл бұрын
How would you use this to sync files across devices similar to how Photos app works
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
This tutorial for the FileManager is specific to the device. If you want to share across devices, you can integrate CloudKit!
@highRider72
@highRider72 3 жыл бұрын
Great video! Quick question: Why are you using a singleton vs an environment object on app level for Local File Manager?
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Hi Hans. Great question.... We use @EnvironmentObject to put an ObservedObject into the environment so that another View can access it. In this video, the LocalFileManager is not observed from the View. Instead, the ObservedObject is our ViewModel and then the ViewModel is referencing the LocalFileManager... The real question would be, why did we use a Singleton, in which case I used a Singleton here because this will be a global class that is used across the app. In a more advanced series I would use Dependency Injection instead.
@highRider72
@highRider72 3 жыл бұрын
@@SwiftfulThinking got it, thank you!
@carlosrivasrocks
@carlosrivasrocks 3 жыл бұрын
Is it possible to sync the data in FileManager across devices with iCloud? How? Thanks!
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Hi Carlos! Well the FileManager is specific to the current device, however, we can use CloudKit to sync across the user's iCloud. That's a whole different framework though.
@xcoo77
@xcoo77 3 жыл бұрын
Great Video! Amazingly explained.
@williamwildsmith5162
@williamwildsmith5162 2 жыл бұрын
Hi Nick, Some of the topics in this set of videos go over my head - firmly my fault (I'm a bit think sometimes, and getting on in years). Anyway, I think you have a talent for training people, and I think you have a winning formula with these individual videos. Great job Nick. How can I buy you coffee?...?
@wandahu8058
@wandahu8058 2 жыл бұрын
May I ask why you deleted the image from the file manager, and then the view did not update immediately but still shows the image.
@wandahu8058
@wandahu8058 2 жыл бұрын
Interestingly, when the get image function is added, the view is still not updated
@AZMerf
@AZMerf 3 жыл бұрын
For example, the Home app allows the user to save an image as a background. I would assume this would be using this concept. Also, can I find the image I saved in the simulator in the folder hierarchy?
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Yea, you should be able to find the file. If you print out the path where we save the image you'll see the exact location. I think it will be pretty deep into the hierarchy though!
@andresraigoza2082
@andresraigoza2082 2 жыл бұрын
You are like my Swift Manual. Thanks again
@OliverHeimann-z4q
@OliverHeimann-z4q 3 ай бұрын
How would you load this steve-jobs image directly from your desktop instead of moving it to the assets folder? Let's assume your are on MacOS, how does this all work with absolute path names instead of these special application folders?
@andrefonseca4901
@andrefonseca4901 2 жыл бұрын
Hi Nick, thanks for all your awesome videos! Just one question: in this video the func getImage retrieves and returns an UIImage. But how can i retrieve and return an mp3 file? What data type should I use in the return?
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
For audio and video, you can write the Data to a URL and then return the URL back to the application. We use AVPlayer to play these files, which can be initialized with a URL. You also can use the remote URL if u don’t want to write to the FileManager, but I often do anyway 👍
@andrefonseca4901
@andrefonseca4901 2 жыл бұрын
@@SwiftfulThinking Thanks a lot Nick, it worked! The reason I couldn’t play the remote URL directly is that I developed my whole player interface (buttons, slider, playing time, etc) using AVAudioPlayer (based on your video Continued Learning #9). But later I found out AVAudioPlayer does not play remote files; only AVPlayer plays remote URLs. So I decided to download the mp3 files in order to use my interface, which is working now. (By the way, it would be nice if you could post a video showing how to make an audio player with slider, controls, etc, using AVPlayer - I tried but was not able to do it).
@dugrut1325
@dugrut1325 2 жыл бұрын
Great video, but how can the user see any files created in Files.app, I notice files I create the are not available to the user, even though I can see them thru terminal. Is there a setting to set in Xcode when the app is compiled, to allow these files accessible to the user/device?
@SwiftfulThinking
@SwiftfulThinking 2 жыл бұрын
The Assets folder is part of the application bundle. It is included in your app when you ship it to the App Store. Therefore, you can read from it but cannot write to it. If you need to write, you should write to a local URL on the device using the FileManager!
@dugrut1325
@dugrut1325 2 жыл бұрын
@@SwiftfulThinking thanks for the reply. I watched the bootcamp series for the second time also going through the Continued Learning series a couple times and now finally it's getting through to this old timer. I seem to understand the howto for path/folders/files. This video exercise I tagged all the functions and them folded them up, It made it short and concise and I finally visualized it. It was a great video. I noticed once you delete the folder you could no longer save the image, so I added the func createFolderIfNeeded() before, to check if the folder was still available. Works
@dugrut1325
@dugrut1325 2 жыл бұрын
@@SwiftfulThinking Thanks for replying. It is, not exactly my question. But I found out the answer. I was asking about writing files through FileManager. I wanted the user to see these files that the app creates. I found through another Swift Tuber to set the 'file sharing' options in Info. Everything with that problem is resolved.
@uguraltnsy
@uguraltnsy 2 жыл бұрын
What should I do for it to appear in the gallery?
@akbar_logs
@akbar_logs Жыл бұрын
I have a question? Question 1: What is the difference between saving Images Externally with the help of Core Data and saving images with the help of File Manager. Question 2: Images saved with the help of File Manager will sync with CloudKit?
@SwiftfulThinking
@SwiftfulThinking Жыл бұрын
1. CoreData doesn’t support image formats and is usually not used for saving Images / Videos / etc. Apps with CoreData will often save “imageUrlString” to CoreData and then load image from FileManager (or elsewhere). 2. FileManager does not sync across devices. I’m not sure if there’s a CloudKit sync option. 3. Most apps will use an Image SDK rather than manually doing it. I wanted to teach an example here, which is important to know and understand, but I would recommend an SDK such as Kingfisher or SDWebImage to load and save the images. In which case, you won’t be dealing w FileManager or CloudKit anyway🤙
@avneetsingh2010
@avneetsingh2010 3 жыл бұрын
Guys I have written the data into a file in documents directory using Swift's standard File manager functions... I am able to view through xcode terminal but while testing in real iOS I don't see any file... Can anyone let me know if it is even possible to view the file???
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
You can do this if you save it on a simulator on your computer. You're probably better off printing out the path from Xcode and then trying to find it. It's a challenge to get to because it's very deep, but I think this may help: stackoverflow.com/questions/25198840/document-directory-path-of-xcode-device-simulator
@МахмуджанНиязов
@МахмуджанНиязов 2 жыл бұрын
how using video files from file manager? please help me
@joywu1
@joywu1 2 жыл бұрын
I found the last step when add manager.deleteFolder() in VM's delete func then only can click save 1 time & many times in delete button, but when I click save again will show files not exit, when I study these code, I found should add manager.creatFolder() in VM's saveImage func, then will no longer show error message. if I delete the folder, it will create folder again when I click save button with no error.
@Денис-ж3ф5р
@Денис-ж3ф5р 3 жыл бұрын
I remember learning SwiftUI with you, which was fun, even though I was forced to learn UIKit. I am happy to understand that I still remember SwiftUI, so you did a great job, I guess.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Haha! That's good to hear. SwiftUI > UIKit though 🥲
@Денис-ж3ф5р
@Денис-ж3ф5р 3 жыл бұрын
@@SwiftfulThinking not always, UIKit words with maps better.
@natgenesis5038
@natgenesis5038 Жыл бұрын
@@Денис-ж3ф5р relax SwiftUI is the best UI tool never seen even tho it still new .
@1slyboy
@1slyboy Жыл бұрын
I noticed that the saved JPEG is much larger than the original JPEG. It would appear that the compressionQuality using 1.0 is not the same as the original quality. BTW - you can see the file saved by the simulator simply by opening the path on your Mac.
@erencelik964
@erencelik964 3 жыл бұрын
Congratulations, it was a really nice content. do you intend to share the code
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Thanks for watching Eren! Yes, the full source code is available on my Github: github.com/swiftfulthinking
@erencelik964
@erencelik964 3 жыл бұрын
@@SwiftfulThinking Thank you for your answer, I hope your content will continue, you are doing very well.
@erencelik964
@erencelik964 3 жыл бұрын
@@SwiftfulThinking Although I know most of the topics you are telling, I'm still watching: D
@emdutt4012
@emdutt4012 Жыл бұрын
I am using Xcode 14.3 while saving the image after first click it shows the save successfully ,but then it's not showing any message.. if anyone here face same problem.
@fre.helfer
@fre.helfer 2 жыл бұрын
👏👏👏👏👏 AMAZING
@akbar_logs
@akbar_logs Жыл бұрын
simply genius
@MrLawaghar
@MrLawaghar 3 жыл бұрын
Great job.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Hey Muhammad.. welcome to the channel! Thanks for watching.
@ThePhotodiver
@ThePhotodiver 3 жыл бұрын
I really enjoyed this video. I am working on an App that uses a JSON file, and would like to create a desktop app that would allow me to create the data for that JSON file that will be used in the first app. This will help me for sure in getting to that point.
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Hi ThePhotodiver! I'm glad the video helped. The code should be very similar except instead of using an Image you just save your JSON data! Thanks for watching.
@김이현시청용
@김이현시청용 3 жыл бұрын
thx!!
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Thank you!! :)
@Jump_Jay
@Jump_Jay Жыл бұрын
Whew this was a long video, but i took small bites out of it until completed. 😁
@wandahu8058
@wandahu8058 2 жыл бұрын
Good!
@Lassund
@Lassund 2 жыл бұрын
NO I love a detailed video, let it be long if it is.
@zamnbro
@zamnbro Жыл бұрын
nahh
@holycrosscv
@holycrosscv 3 жыл бұрын
This is a really helpful series! Thanks so much! To get rid of the pesky constraint errors in the output, just add the following to the to the @main first view: .onAppear { UserDefaults.standard.setValue(false, forKey: "_UIConstraintBasedLayoutLogUnsatisfiable") }
@SigmaPC94
@SigmaPC94 2 жыл бұрын
You are the best can I have your insta handle please 😍😍
@mig12394
@mig12394 3 жыл бұрын
Awesome, better and better 👍
@SwiftfulThinking
@SwiftfulThinking 3 жыл бұрын
Thanks as always Michel!
Save and cache images in a SwiftUI app | Continued Learning #27
24:04
Swiftful Thinking
Рет қаралды 13 М.
SwiftData Basics in 15 minutes
15:18
CodeWithChris
Рет қаралды 55 М.
UFC 287 : Перейра VS Адесанья 2
6:02
Setanta Sports UFC
Рет қаралды 486 М.
Play: The Secret Weapon for iOS Devs & Designers
10:12
Sean Allen
Рет қаралды 39 М.
CloudKit - Intro, Pricing, Terms, & Definitions
17:26
Sean Allen
Рет қаралды 24 М.
Stop using GeometryReader in SwiftUI
4:27
Flo writes Code
Рет қаралды 6 М.
Sort, Filter, and Map data arrays in Swift | Continued Learning #13
28:36
Swiftful Thinking
Рет қаралды 22 М.
New SwiftUI Photo Picker - Single & Multiple Selection
12:42
Sean Allen
Рет қаралды 12 М.
SwiftUI - Intro to MVVM | Example Refactor | Model View ViewModel
11:55