1

Looking to assign inout array parameter to local var but getting error

Escaping closures can only capture inout parameters explicitly by value

Following is the code

func setData( feedsData:  inout [FeedStruct]) {
        DispatchQueue.main.async {
            self.arrData = feedsData // here is the error
    ....
Ali Jawad
  • 151
  • 1
  • 13
  • 1
    You haven't shown enough code to understand why you are using `inout` but I strongly suggest you avoid `inout` parameters. As explained in the duplicate they are especially unsafe when combined with asynchronous execution. – Paulw11 Aug 23 '17 at 12:29
  • [This solution](https://stackoverflow.com/a/51619714/2880627) show how to modify a pass-by-reference variable in an escaping closure. – ukim Jul 31 '18 at 18:22

0 Answers0