If the file exists it will be sent back to us, otherwise we’ll get back nil, so this is an optional URL. If we want to read the URL for a file in our main app bundle, we use (). However, URLs are a bit more powerful than just storing web addresses – they can also store the locations of files, which is why they are useful here. This uses a new data type called URL, which stores pretty much exactly what you think: a URL such as. Although these get included with our app’s download from the App Store, these other bundles are stored separately from our main app bundle – our main iOS app code and resources.Īll this matters because it’s common to want to look in a bundle for a file you placed there. In the future, as your skills grow, you’ll learn how you can actually include multiple bundles in a single app, allowing you to write things like Siri extensions, iMessage apps, widgets, and more, all inside a single iOS app bundle. This happens on all of Apple’s platforms, including macOS, and it allows the system to store all the files for a single app in one place – the binary code (the actual compiled Swift stuff we wrote), all the artwork, plus any extra files we need all in one place. When Xcode builds your iOS app, it creates something called a “bundle”. This also applies if you have specific data formats such as XML or JSON – it takes the same work regardless of what file types you’re loading. When we use Image views, SwiftUI knows to look in your app’s asset catalog to find the artwork, and it even automatically adjusts the artwork so it loads the correct picture for the current screen resolution – that’s the and stuff we looked at earlier.įor other data, such as text files, we need to do more work.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |