Xcode and Reading documents from a URL connection.

I have an Xcode app where currently txt files in the project display text data as a list. I can search through the lists and have buttons that will swap between different lists of information that you can look through.

The next task is I have URL connections to docx files on a SharePoint site. I am trying to use an URLsession function to connect to the URL links to download the documents to the document directory then have the application read the doc information to then be displayed as the txt info would.

The idea is that the docx files are a type of online update version of the data. So when the app is used and on wifi, the app can update the list data with the docx files.

I have code set up that should access the URL files but I am struggling to figure out how to read the data and access from this Documents directory. I have been looking online and so far I am at a loss on where to go here.

If anyone can help or provide some insight I would greatly appreciate it.

I can try and provide code samples to help explain things if that is needed.

There seems to be multiple parts to your question:

  • Downloading content
  • Managing files in the Documents directory
  • Displaying that content

Which one are you having problems with?

This is important because it informs how to route your question. For example, if you’re having problems with URLSession then that’s something I can help you with, but I’m not the best person to talk to about UI frameworks.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I do use URLsession. From what I could find with research online and even checking with ChatGPT for more specific questions on the topics that seemed to be what I needed to allow the app to connect to a website and use URL links to download docx files for the app.

The problem that I am seeing is I am not sure if I am using the URLsession correctly or if there are additional steps I need to take when it comes to accessing this Documents Directory that is on the mobile device itself to access the documents.

From my own testing when Io run the app I try checking documents on the mobile device but nothing looks to update so my guess is I am not using the URLsession function correctly.

I am a beginner still with using swift and Xcode so I am trying to learn as much as I can for working on this project.

My Project is setup with multiple .view scripts to handle different parts of the app itself.

They are setup as follows: ContentView This script is used for viewing the app itself where I have buttons displayed that swap between different lists that could be viewed and searched through using the searchable modifier.

This function works correctly and I can change the lists by pressing the buttons just fine.

The listed data comes from txt files in the project as test data to work with.

FileUpdater This file would be used to download the docx files from the URL links when the device is connected to a specific wifi network that I have listed and set to check for the needed connection. I also have the URL links as well.

This should also download the files to save locally.

FileLoader This script is supposed to take the docx data that was downloaded and upload it to the txt files by conversion and writing the data and this whole process is a type of online update system. So when the online docx are modified the list will stay up to date with the new information when I use the app to search through.

FileInitializer This script is a singe run that is used to copy the bundle txt files to the document directory on the first launch of the app. This should help with the data conversion being done in my other scripts as mentioned.

The final two scripts are as follows: HighlightHelper SearchTextChangeHandler

These are small scripts used to help with the basic search functionality when using the application.

I am sorry if this is adding too much information or detail but I hope this helps understand what I am trying to create with this project.

Xcode and Reading documents from a URL connection.
 
 
Q