uncleFedEx uncleFedEx - 1 year ago 123
Swift Question

Swift: How to pass NSView's array data to AppDelegate?

I need to pass an array of CGPoints from NSView.swift to AppDelegate.swift. What is the robust method to do that?

Answer Source

Update your AppDelegate.swift like this:

import Cocoa    
class AppDelegate: NSObject, NSApplicationDelegate {

        var myArray : Array = [] // add this variable definition


This you will need to do in NSView.swift, when passing data to appDelegate.

let appDelegate = NSApplication.shared().delegate as! AppDelegate        
appDelegate.myArray = myArray
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download