mattdipasquale mattdipasquale - 4 months ago 15
Swift Question

Swift: Pass array by reference?

I want to pass my Swift

Array
account.chats
to
chatsViewController.chats
by reference (so that when I add a chat to
account.chats
,
chatsViewController.chats
still points to
account.chats
). I.e., I don't want Swift to separate the two arrays when the length of
account.chats
changes.

Answer

I ended up just making account a global variable and defining the chats property of ChatsViewController as: var chats: [Chat] { return account.chats }. For details, see Acani Chats.