Extelligent Cocoa
Because one brain is not enough
RSS
  • Home
  • About…
  • Sticky: Welcome to Extelligent Cocoa (version 3)

    Sticky: Welcome to Extelligent Cocoa (version 3)

  • NSOutlineView: Saving expansion status

    NSOutlineView: Saving expansion status

  • Saving a font to UserDefaults

    Saving a font to UserDefaults

  • Disclosure Triangle (Autolayout)

    Disclosure Triangle (Autolayout)

  • NSColorWell/NSTextField Bug

    NSColorWell/NSTextField Bug

  • Get the modification (or creation) date of a file

    Get the modification (or creation) date of a file

  • NSDocumentController basics

    NSDocumentController basics

  • Protocols and Equality

    Protocols and Equality

Sticky: Welcome to Extelligent Cocoa (version 3)

Dec 30 2016

Sticky: Welcome to Extelligent Cocoa (version 3)

Terry Pratchett uses the term ‘Extelligence’ for the habit of storing information outside oneself. This Blog mainly exists to stand on the shoulders of giants and to store information in an accessible manner so that once I have solved a problem, I do not have to solve it again. ‘And because WordPress is a decent […]

By Extelligent Cocoa • EC Meta •

NSOutlineView: Saving expansion status

Aug 7 2020

NSOutlineView: Saving expansion status

(This is not the promised Part III of my previous series. Which is not fully functional and needs an overhaul, but right now, I am lacking time.) In most cases, users expect to find outline views as they left them. So I needed a different solution. Whether an item is expanded or not is, strictly […]

By Extelligent Cocoa • Application Design, Interface • • Tags: NSOutlineView

Saving a font to UserDefaults

Mar 29 2020

Saving a font to UserDefaults

(Here using macOS 13, Xcode 10, Swift 4.2, but NSFontDescriptor also exists on iOS, just substitute UIFont). The recommended way of saving a font is not to do it (a bit flippant, sorry) – but in WWDC session 223 from 2013 (Using Fonts with TextKit), the recommendation is specifically to a) not cherry-pick attributes (in […]

By Extelligent Cocoa • Interface, Wiki • • Tags: NSFont, NSFontDescriptor, NSTextField, UserDefaults

Disclosure Triangle (Autolayout)

Sep 15 2019

Disclosure Triangle (Autolayout)

(Xcode 10, Swift 4.2, macOS 13.6) This is a common use case: users who just want an overview get a smaller window with the most important content, users who want more detail can click a triangular button and more details unfold. I seem to have tackled this problem several times without feeling completely happy with […]

By Extelligent Cocoa • Application Design, Bug Reports, Interface, Tutorials • • Tags: Autolayout, disclosure, embed view

NSColorWell/NSTextField Bug

Jan 29 2019

NSColorWell/NSTextField Bug

Xcode 10, Swift 4.2, macOS 10.13. I have two text fields in my preference controller. Their purpose is to allow users to set a preferred default text style, which I will use elsewhere in my application. (This can be handled much more smoothly, but I have other problems to work out, and right now, working […]

By Extelligent Cocoa • Bug Reports, Interface • • Tags: NSColorWell

Get the modification (or creation) date of a file

Jan 28 2019

Get the modification (or creation) date of a file

Xcode 10, Swift 4.2, macOS 10.13 func fileModificationDate(url: URL) -> Date? { do { let attr = try FileManager.default.attributesOfItem(atPath: url.path) return attr[FileAttributeKey.modificationDate] as? Date } catch { return nil } } FileAttributeKey.creationDate works exactly the same; .size and .type might also be of interest. This beautiful and elegant solution comes from this Stackoverflow answer and […]

By Extelligent Cocoa • File Handling, Wiki • • Tags: FileAttributeKey, FileManager

NSDocumentController basics

Jan 13 2019

NSDocumentController basics

Xcode 10, macOS 13.5, Swift 4.2 Without wanting to delve too deep into the NSDocumentController class: It’s part of the document architecture, and if your app uses more than one NSDocument subclass, you will need to override the following method: override func makeUntitledDocument(ofType typeName: String) throws -> NSDocument { switch typeName { case “ThingB”: return […]

By Extelligent Cocoa • File Handling, Wiki • • Tags: AppDelegate, NSDocumentController, singletons

Protocols and Equality

Aug 9 2018

Protocols and Equality

I recently found myself in the position where I am happily using a protocol, and needed to work with equality in a context that can be summed up as: var currentObject: MyProtocol = Thing1() { willSet{ if newValue != currentObject { //perform costly operation } } (But really, equality is everywhere. Want to get the […]

By Extelligent Cocoa • Application Design, Design Patterns •

The exceedingly strange case of SKView

May 27 2018

The exceedingly strange case of SKView

Xcode 9.3; macOS 10.12.6 This came out of the strange case of the scrolling SpriteKit View, which did – in the end – work fine (as in, my SpriteKit scene was displaying) and failed when I tried to add interactions to it. As a result, I went back to the drawing board, played some more […]

By Extelligent Cocoa • Bug Reports, Graphics, Interface, SpriteKit • • Tags: NSView, SKScene, SKView

Problem solving: The strange case of the scrolling SpriteKit View

May 22 2018

Problem solving: The strange case of the scrolling SpriteKit View

(Xcode 9.3; macOS 10.12.6, Swift 4) If you want a challenge, I recommend you try to implement ‘scrolling SpriteKitView’ yourself before you read the rest of this article. Update (and spoiler): Due to a bug in InterfaceBuilder’s ‘SKView’, you need to use a ‘custom View’ (NSView) in Interface Builder, and change its type to SKView. […]

By Extelligent Cocoa • Bug Reports, Coding Meta, Interface, SpriteKit • • Tags: NSScrollView, SKView

CoreData Guidelines

May 15 2018

CoreData Guidelines

This article on CoreData rules is the most concise I have seen. While I have looked at CoreData in some detail and used it in smaller projects, I have never felt completely confident about some of its more esotheric properties and I still flail at questions like ‘So how do I best save my data […]

By Extelligent Cocoa • Application Design, Resources • • Tags: Core Data

1 2 3 4 5 >»

Categories

  • Application Design
  • Bug Reports
  • Coding Meta
  • Design Patterns
  • EC Meta
  • Extensions
  • File Handling
  • Frameworks
  • Graphics
  • Interface
  • Operators
  • Real World Swift
  • Resources
  • SpriteKit
  • Teaching Programming
  • Tutorials
  • Wiki

Recent Posts

  • NSOutlineView: Saving expansion status
  • Saving a font to UserDefaults
  • Disclosure Triangle (Autolayout)
  • NSColorWell/NSTextField Bug
  • Get the modification (or creation) date of a file

Archives

  • August 2020
  • March 2020
  • September 2019
  • January 2019
  • August 2018
  • May 2018
  • March 2018
  • February 2018
  • January 2018
  • December 2017
  • November 2017
  • October 2017
  • July 2017
  • June 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016

Recent Wiki

  • Saving a font to UserDefaultsSaving a font to UserDefaults
    (Here using macOS 13, Xcode 10, Swift 4.2, but
  • Get the modification (or creation) date of a fileGet the modification (or creation) date of a file
    Xcode 10, Swift 4.2, macOS 10.13 func
  • NSDocumentController basicsNSDocumentController basics
    Xcode 10, macOS 13.5, Swift 4.2 Without wanting to
  • NSStackView TutorialNSStackView Tutorial
    (Xcode 9, macOS 10.12, Swift 4) Stackviews exist
  • Filetypes and UTIsFiletypes and UTIs
    macOS 10.12 (I will update this post once I’ve

Tags

AppDelegate Autolayout closures Codable containerView Core Data disclosure embed view enums FileAttributeKey FileManager generics initialFirstResponder NSAlert NSApplication.ModalResponse NSApplicationDelegate NSButton NSCoding NSColorWell NSDocumentController NSFont NSFontDescriptor NSImageView NSKeyedArchiver NSKeyedUnarchiver NSOpenPanel NSOutlineView NSPopover NSSavePanel NSScrollView NSStackView NSStoryboardSegue NSTextField NSTextFieldDelegate NSTitlebarAccessoryViewController NSToolbar NSToolbarItem NSView NSWindowController sheets singletons SKView storyboards UserDefaults zoom

↑

© Extelligent Cocoa 2023
Powered by WordPress • Themify WordPress Themes