(NSMenuItem):缺少setter或实例变量 [英] (NSMenuItem): missing setter or instance variable

查看:279
本文介绍了(NSMenuItem):缺少setter或实例变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个奇怪的错误:

I am encountering a strange error:

2015-04-02 12:20:14.642 test[21167:257788] Failed to connect     
(testApp) outlet from (test.AppDelegate) to (NSMenuItem): missing 
setter or instance variable
inserted id: 122

我在向菜单添加menuItem并将功能连接到菜单时发生.

I occured when a added a menuItem to a menu and connected a function to it.

我不知道问题是什么.该应用程序工作正常,但我认为忽略该错误不是一个聪明的主意. setter或instance变量是什么意思?为什么需要它?

I do not know what the Problem is. The app works fine but i don't think it is a smart idea to ignore the error. What is meant by setter or instance variable? Why is it needed?

更新:这是相关代码:

import Cocoa
import Foundation

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

@IBOutlet weak var window: NSWindow!
@IBOutlet weak var statusMenu: NSMenu!

let statusItem = NSStatusBar.systemStatusBar().statusItemWithLength(-1)

func applicationDidFinishLaunching(aNotification: NSNotification) {
    let icon = NSImage(named: "statusIcon")

    statusItem.image = icon
    statusItem.menu = statusMenu
    // Time for constant repeat
    NSTimer.scheduledTimerWithTimeInterval(1, target: self, selector: "timerRepeat", userInfo: nil, repeats: true)
}

// Method to call the tracking core
func timerRepeat() {
    //....
}

@IBAction func frontEnd(sender: NSMenuItem) {
    var targetURL : String = NSBundle.mainBundle().resourcePath!
    targetURL = targetURL + "/" + "front.app"
    let workspace = NSWorkspace()
    workspace.launchApplication(targetURL)
}


@IBAction func menuClicked(sender: NSMenuItem) {
    NSApplication.sharedApplication().terminate(self)
}   
}

推荐答案

您的xib文件中的插座已损坏.通常,当您为ivar或属性设置出口,然后不使用Xcode的重命名功能将其删除或重命名时,就会发生这种情况.

You have a broken outlet in your xib file. Usually it happens when you set up an outlet to ivar or property which is later deleted or renamed not using Xcode's rename feature.

这篇关于(NSMenuItem):缺少setter或实例变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆