Use _NS_4445425547
or NS🐞
for enables debuggging panel. When enabled it, a ladybug 🐞 menu appears in the app menu bar.
“4445425547” means DEBUG in Unicode table.
0x44=D
0x45=E
0x42=B
0x55=U
0x47=G
I found some documentation of the types returned by method_copyReturnType()
in the Objective-C runtime API. These mysterious characters are called Type Encodings in Objective-C and are unique codes represented by one or fewer characters.
I note it here for my own benefit.
c
= charB
= BOOL / bool / _bools
= shorti
= intI
= unsigned int?l
= longimport Cocoa | |
extension NSView { | |
var isFirstResponder: Bool { | |
window?.firstResponder == self | |
} | |
} |
import Cocoa | |
extension NSImage { | |
/// Return dimmed NSImage with level (0.0–1.0) | |
func dimmed(_ level: CGFloat) -> NSImage { | |
NSImage(size: self.size, flipped: false) { rect in | |
let imageRect = NSRect(.zero, self.size) | |
// Draw image |
#!/bin/sh | |
echo "$1" | \ | |
sed -E 's/(https:\/\/www\.amazon\.co\.jp)\/.*\/([0-9A-Z]{10})[\/\?]?.*/\1\/dp\/\2/' | |
# % amazonurl.sh "https://www.amazon.co.jp/構造化ユーザインタフェースの設計と評価/dp/4320029968" | |
# % https://www.amazon.co.jp/dp/4320029968 |
// Dump all NSApplication’s class methods | |
let dump = NSApplication.perform(NSSelectorFromString("fp_methodDescription")).takeUnretainedValue() as? String | |
// Dump all NSApplication’s instance methods | |
let dump = NSApp.perform(NSSelectorFromString("fp_methodDescription")).takeUnretainedValue() as? String | |
// or | |
print(NSApplication.value(forKey: "fp_methodDescription")) | |
print(NSApp.value(forKey: "fp_methodDescription")) |
"Arguments Passsed on Launch" on Xcode:
-NSShowAllViews YES
import Cocoa | |
class SplitView: NSSplitView { | |
override var dividerThickness: CGFloat { | |
50 | |
} | |
override var dividerColor: NSColor { | |
NSColor.red |
import Foundation | |
extension IndexPath { | |
enum IndexPathFromStringError: Error { | |
case couldNotInitialize(String) | |
} | |
/// Initialize with description. e.g. "[2, 3, 12, 0, 4]" | |
init(from description: String) throws { |
AppKitのNSWindowControllerをNSWindowDelegateにする場合に、なぜだかデリゲートメソッド一式がコールされない現象に悩まされた。調べても原因がよくわからず、NSWindow.delegateの中身を確認しても正しくNSWindowControllerインスタンスが設定されているので、一体どこで通知不能になっているのかが掴めなかった。
一応解決できた方法としては、NSWindowController.showWindow(_:)をオーバーライドし、superのコール前にデリゲートを再設定してあげることでこのコールされない現象を解消できた。
// MyWindowController.swift
override func showWindow(_ sender: Any?) {