if have 2 swift classes AppDelegate.swift and Other.swift I'm trying to call a function thats in Other.swift from AppDelecage.swift but I'm getting an error
this is what I'm doing
Other.swift
AppDelegate.swift
fatal error: unexpectedly found nil while unwrapping an Optional value
this is what I'm doing
Other.swift
Code:
import Foundation
import Cocoa
class Other: NSObject, NSTextFieldDelegate {
@IBOutlet weak var mytextfield: NSTextField!
func myfunction() {
mytextfield.stringValue = "whatever"
}
}
AppDelegate.swift
Code:
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBActionfunc CallFunction(sender: AnyObject) {
Other().myfunction()
}
}