I am having a strange problem and I was wondering if you could help me out with it. I have this code:
However, when it gets to the line that says:
I am getting this error:
"'NSTextField' does not have a member named 'text'"
Any ideas why I can't set a simple Label? Thanks!
Code:
import Cocoa
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@IBOutlet weak var window: NSWindow!
@IBOutlet weak var lblLeadsCount: NSTextField!
@IBOutlet weak var lblLastChecked: NSTextField!
func applicationDidFinishLaunching(aNotification: NSNotification?) {
// Insert code here to initialize your application
}
func applicationWillTerminate(aNotification: NSNotification?) {
// Insert code here to tear down your application
}
@IBAction func checkLeads(sender: AnyObject) {
var url = NSURL(string: "http://*********************")
let theRequest = NSURLRequest(URL: url!)
NSURLConnection.sendAsynchronousRequest(theRequest, queue: nil, completionHandler: {(response: NSURLResponse!, data: NSData!, error: NSError!) -> Void in
if data.length > 0 && error == nil {
let response : AnyObject! = NSJSONSerialization.JSONObjectWithData(data,
options: NSJSONReadingOptions.MutableContainers, error: nil)
lblLeadsCount.text = response
}
})
}
}
However, when it gets to the line that says:
Code:
lblLeadsCount.text = response
I am getting this error:
"'NSTextField' does not have a member named 'text'"
Any ideas why I can't set a simple Label? Thanks!
Last edited: