小编Mat*_*ler的帖子

在OS X的Dock上下文菜单中显示图标?

我的问题很简单:

要在码头上使用自定义菜单的应用程序图标,- (NSMenu*) applicationDockMenu: (id) sender;NSApplicationDelegate必须返回码头将显示菜单.

使用setImageNSMenuItem,你可以normaly图标添加到菜单.它们出现在普通菜单上,但不会出现在应用程序停靠栏图标的上下文菜单中.

那么Apple如何管理QuickTime,XCode,预览以在其停靠上下文菜单中可访问的最近打开的文件列表中显示图标?

谢谢.

macos cocoa objective-c

6
推荐指数
1
解决办法
957
查看次数

我怎么知道关闭按钮关闭NSWindow?

有没有一种简单的方法可以通过关闭按钮(窗口标题栏)来确定何时关闭NSWindow.

使用NSWindowDelegatewindowWillClose:(NSNotification *)notification方法我得到每个结束的通知.但是我怎么知道关闭请求是通过关闭按钮发送的

cocoa nswindow

6
推荐指数
1
解决办法
3024
查看次数

关闭作为UITableViewCell子类的属性来更新值:这是一个坏主意吗?

我想对我刚才的想法提出一些看法:

我有一堆UITableViewCell子类.在我的特定情况下,它只是添加一个UISwitch并具有访问它的属性.

设置开关的值是直截了当的.更新与此开关关联的Bool并非如此.

我想添加一个闭包作为我的单元格的属性,以便我可以调用它来更新我的UITableViewController子类中的bool

这是我想到的一些代码:

class SwitchTableViewCell:UITableViewCell {
    @IBOutlet var theSwitch:UISwitch!

    var switchValueChangedBlock:((Bool) -> Void)?

    override func awakeFromNib() {
        theSwitch.addTarget(self, action: "switchValueChanged", forControlEvents: .ValueChanged)
    }

    deinit {
        theSwitch.removeTarget(self, action: nil, forControlEvents: .AllEvents)
    }

    func setCallback(callback:(Bool) -> Void) {
        switchValueChangedBlock = callback
    }

    func switchValueChanged() {
        switchValueChangedBlock?(theSwitch.on)
    }
}
Run Code Online (Sandbox Code Playgroud)


class myTableViewController:UITableViewController {
    var alarmEnabled:Bool = true
 ...
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell:UITableViewCell?
        if indexPath.section == enableSection {
            cell = …
Run Code Online (Sandbox Code Playgroud)

closures uitableview ios swift

6
推荐指数
1
解决办法
830
查看次数

有什么方法可以将点击绑定到 ng-container 吗?

我有一个由 a 组成的组件ng-container,我想在它上面绑定一个点击。(click)不做这项工作。

还有其他方法吗?

angular ng-container

6
推荐指数
1
解决办法
1万
查看次数

为什么 a = null ?[] 类型 never[]?

为什么我在这里得到不同的数组类型推断?

const a = []; // any[]
const b = null ?? []; // never[] 
Run Code Online (Sandbox Code Playgroud)

演示在这里

type-inference typescript typescript-never

6
推荐指数
1
解决办法
207
查看次数

Angular 开发服务器错误通道:handleResponse UNK/SW_UNREACHABLE 选项 getValue 中出错

我最近安装了一个新的角度应用程序。在执行 ng 服务时,应用程序被加载。但几秒钟后我在控制台中收到一些奇怪的错误。

Channel: Error in handleResponse UNK/SW_UNREACHABLE options getValue
_handleResponsePromise @ commons.js:2
(anonymous) @ commons.js:2
7commons.js:2 
Uncaught (in promise) Error: Could not establish connection. Receiving end does not exist.
fromGeneric @ commons.js:2
fromAny @ commons.js:2
_handleResponsePromise @ commons.js:2
(anonymous) @ commons.js:2
Run Code Online (Sandbox Code Playgroud)

不知道为什么会发生这个错误。我的package.json内容如下

"dependencies": {
    "@angular/animations": "^14.1.0",
    "@angular/common": "^14.1.0",
    "@angular/compiler": "^14.1.0",
    "@angular/core": "^14.1.0",
    "@angular/forms": "^14.1.0",
    "@angular/material": "^7.0.0",
    "@angular/platform-browser": "^14.1.0",
    "@angular/platform-browser-dynamic": "^14.1.0",
    "@angular/router": "^14.1.0",
    "jwt-decode": "^3.1.2",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^14.1.1",
    "@angular/cli": "~14.1.1",
    "@angular/compiler-cli": "^14.1.0", …
Run Code Online (Sandbox Code Playgroud)

javascript angular

6
推荐指数
1
解决办法
2657
查看次数

为什么sed不能在我的bash脚本中工作?

这是我的代码.我只是想复制一些文件并替换我的Makefile中的一行.参数$ 1只是我的新.tex文件的名称.

#!/bin/bash                                
pwd="./"                                   
tex=".tex"                                 
pwd=$1$tex                                 
cp ~/TeX/matt.sty .                        
cp ~/TeX/mon.tex $pwd                      
cp ~/TeX/Makefile .                        

sed="sed 's/mon.tex/"$1$tex"/g' Makefile > Makefile"           
$sed
Run Code Online (Sandbox Code Playgroud)

我有以下错误: sed: 1: "'s/mon.tex/salut.tex/g'": invalid command code '

ps:我在Mac OS X上使用sed.(所以它是bsd sed)

bash sed

5
推荐指数
1
解决办法
2990
查看次数

Grunt/PhoneGap:警告:超出了stdout maxBuffer

Warning: stdout maxBuffer exceeded当我使用我的grunt脚本启动iOS模拟器时,我会得到以下消息.

知道什么可以触发这个吗?

这是我的Gruntfile的一部分:

grunt.registerTask('emulator', 'Launch an emulator', function (platform, targetId) {
    if (arguments.length === 0 || !platform) {
        grunt.fail.fatal('No platform was specified');
    } else {
        grunt.log.writeln('We launch the emulator for ' + platform);

        if (targetId) {
            grunt.log.writeln('Specified targetId: ' + targetId);
        }

        var fs = require('fs'), execInstance, directoryPath, command, done = this.async();

        if (platform === 'ios') {
            directoryPath = phoneGapBuildPath + '/platforms/' + platform.toLowerCase() + '/cordova/';
            command = './run';
        } else {
            directoryPath = phoneGapBuildPath + …
Run Code Online (Sandbox Code Playgroud)

macos ios cordova gruntjs

5
推荐指数
1
解决办法
4472
查看次数

TypeScript:无法识别ES2015字符串属性“重复”

条件:我正在使用Win10,TypeScript 1.8和Visual Studio Code 1.0.0。我有类似的代码

///<reference path = "./typings/lib.es6.d.ts" />
Run Code Online (Sandbox Code Playgroud)

然后

let z = "0".repeat(4 - str.length)
Run Code Online (Sandbox Code Playgroud)

这是let z线。

VS Code在“重复”下加上红色下划线并报告

[ts] Property 'repeat' does not exist on type 'string'.
Run Code Online (Sandbox Code Playgroud)

我在命令行上用

tsc <filename>.ts
Run Code Online (Sandbox Code Playgroud)

指向repeatlet z行的开头,编译器报告

error TS2339: Property 'repeat' does not exist on type 'string'.
Run Code Online (Sandbox Code Playgroud)

开始时有所不同,TypeScript,但这是ES2015(ES6)所添加的。

问题:如何获得干净的编译文件?

编辑:缩短。

typescript

5
推荐指数
1
解决办法
2857
查看次数

“browser-esbuild”和“application”构建器有什么区别?

文档说明

我在文档中看到了这一点,但我很困惑。谁能更好地向我解释一下吗?

起初我以为“应用程序”是针对SSR的,但我不知道它们之间的真正区别。

angular angular-builder esbuild

5
推荐指数
1
解决办法
1073
查看次数