July 15, 2018

[Tips] macOS/iOS Programming Tips



The page "How do I get default title bar height of a NSWindow" defines following code to get the height of window title bar.

extension NSWindow {
    var titlebarHeight: CGFloat {
        let contentHeight = contentRect(forFrameRect: frame).height
        return frame.height - contentHeight


The NSTextField whose "isEnabled" flag is false will have NO width in the NSStackView. To Expand width of it, you have to give constraint to the NSTextField object in the NSStackView.


Open panel and bookmarking

You have to allow read and write access even if write operation is not required. Because updating preference data require write operation. In this case, check the link target on XIB object:








Command line arguments

If you launch the application from Xcode build phases, following command line options are given: -NSDocumentRevisionsDebugMode, YES.

Compile error

What to do when the following error is occurred:
  • resource fork, Finder information, or similar detritus not allowed: See StackOverflow.
  • this class is not key value coding-compliant for the key: The link between XIB object and source code nay be broken
  • /usr/bin/codesign failed with exit code 1: try to clean up keychain.app

Log output

After updating Xcode to Xcode9 (or after my unintended operation), The Xcode does not display the log of compilation process.To display the log, I changed the Xcode Preference:
Xcode menu -> Preference -> Select "Build/Start" item -> Check the "navigator to current log"
By this setting, the compile log is displayed in the current editor view.


No comments: