Working on the upload section of my app, after uploading a file from the iPhone, the server puts the file through multiple processing stages.
I use a struct that keeps the uploaded file info, scripts to call, etc.
struct XFile {
let key: String
let filename: String
let data: Data
var mimeType: String?
let url: URL
var toUrl : URL?
var upStatus : UpStatus?
var fileStage : Int32?
init(fileUrl: URL, key: String) {
//setting multiplle variables here
//set the initial fileStage to 0
self.fileStage = 0
}
}
I declare and create my XFile structure from within my UIViewControler with:
class UploadFile : UIViewController, URLSessionDelegate {
var xFile : XFile?
//buttonAction
xFile = XFile(fileUrl: url, key: "filename")
}
When I attempt to change xFile.fileStage from within XFile itself, or within the UIViewControler that created that instance of XFile, I have no problems.
However, if I pass xFile as a parameter into a different class's function, I cannot change the variable xfile.fileStage without getting the following compiler editor:
Cannot assign to property: 'xFile' is a 'let' constant
However, I do not get the error if I send xFile as a reference to xFile to that 3rd class.
getService.start(upFile: &xFile!, upLoadInvoiceClass: self)
Is this normal behavior?
Is it that passing xFile in a function sends a copy?
I just want to make sure I am understanding AND using it properly.