Explanation
In my app I want to add the ability to export the data of a member. Im talking about all the transactions of the member. This is what I have, I hope it's clear what I'm asking. What do I have to edit, that it works? Or is my way the right?
var str: [String] = []
for trans in (member?.transactions!)! {
let trnsctnr = trans.reason
let trnsctna = String(trans.money)
var trnsctnd = ""
if let trnsd = trans.date{
trnsctnd = dateFormatter.string(from: trnsd)
}
str = [trnsctnr, trnsctna, trnsctnd] as! [String]
}
This code doesn't work. I want to add this in a 'MFMailComposerController' and than this error is shown :
Cannot convert value of type 'Never' to expected argument type 'String'
So I want to export the data of all transactions which the member did.
What I did as a computed property:
struct stringForMFMail {
let trnsctnr = transaction?.reason
var trnsctna = ""
if let trns = transaction?.money {
trnsctna = String(trns)
}
var trnsctnd = ""
if let trnsd = transaction?.date{
trnsctnd = dateFormatter.string(from: trnsd)
}
let dataString = [trnsctnr, trnsctna, trnsctnd]
}
This doesn't work at all, so I'm sure I did it completely wrong. There are some errors like: Struct declaration cannot close over value 'self' defined in outer scope. Totally there are 12 error in this little part so I did something really wrong.
