|
Hi guys, Been fighting with this for the whole day and totally ran out of ideas. The task is: For a tougher challenge, take the image generation code out of So, totally confused with what I was supposed to do, I took a look at a different user's code, which is:
...and I have absolutely NO idea why it is what it is. I assume that the main aim of this is a performance boost for the app. But only saving the data, without reading it at the next app launch is pointless. How can we read the data from the documents directory file? Each of the string is UUID string, so I don't even know what I should be looking for. I looked at the project 10 again and I have a weak assumption that I should read the UUID from some array consisting of the saved paths, but here is where I'm out of ideas. As always, any help will be greatly appreciated :) |
|
The idea of this challenge is to prevent delays in showing/scrolling the table view due to the process of reading the image files. So, he asks you to read all the images upon app launch, so that they're all already in memory when you show the table view. All you need to do is read and images and put them in an array of images: On the Hope that cleared it up. |
|
Hi, so the first task of this challenge is to not do the image resizing in So you need to resize all the images when app launches, store them in dictionary to access them by filename quickly and that is basic solution done. Or you can go for the second part and also save the resized images to the documents folder. Then when the app launches next time you can just read from disk inside these smaller ones and display them. If you transform the images names in predictable fashion for example with preffix |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure and A/B test your entire paywall UI without any code changes or app updates. Sponsor Hacking with Swift and reach the world's largest Swift community! |
|
Hi guys, Thanks for the explanation. However, I am still clueless about how to READ the saved data from the DOCUMENTS DIRECTORY (sorry for the caps, didn't mean to be aggressive, just underlining the issue :D). In the method I showed you, each of the images is saved as some UUID string. How can I read those on the launch of the app? |
|
I've something similar in my project. You have to adjust it to your needs, but it should get you started ...
|
|
The base documents URL is still the same for the app installation. So if you get the URL, append filename (like |
|
Hi guys, thank you so much for your replies, it means a lot to me. I tried my best and I managed to save all images URLs into an
} |
|
That's a lot of code for us to dissect. Try to go at it small chuncks at a time and debug (at the least with print()). For starters
Are these getting set properly instead of returning early ? |
|
Yes, everything checks out, there are no errors or any pre-mature returns on the way. HOWEVER, I noticed that when I printed out the file URL of the first image saved, which looked like this: /Users/macbook/Library/Developer/CoreSimulator/Devices/1F615CE7-A66D-458D-B0DF-0AB763505B4A/data/Containers/Data/Application/5C9B0CED-37DC-4DCB-A20C-69CC49A54EC5/Documents/F24175AF-F2DE-4847-8D7B-359FF20DDDB1 I tried to enter the URL into Finder so I could check if the image had been indeed created, but Finder is not able to access the provided URL, as if it didn't exist. What can the possible reason for it? |
|
if the URL is correct you should see the documents directory of your simulator when pasting this int finder
If that doesn't work at all, you didn't get the right URL for the documents directory. If you see an empty directory, there's something going wrong with the filename. try doing a simple test with loading just one image from 1 url in viewDidLoad. If you get that to work, you should be on your way ... |
|
@MateusZ: When you said the interface doesn't load the images, are you talking about the main vc or the detail VC? Because I copied your code into a new swift file and was able to compile the app just fine with some small changes below.
I hope this helped at all :/ I am still new at coding .. |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure and A/B test your entire paywall UI without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.