How to check file under Library in macOS
Issue #200
1 | let home = NSSearchPathForDirectoriesInDomains(.applicationScriptsDirectory, .userDomainMask, true).first! |
Issue #200
1 | let home = NSSearchPathForDirectoriesInDomains(.applicationScriptsDirectory, .userDomainMask, true).first! |
Issue #178
Install ffmpeg, which installs ffprobe
1 | brew install ffmpeg |
Find location of installed ffmpeg
1 | which ffmpeg |
Add all executables to project
Get error
unable to obtain file audio codec with ffprobe
Run in verbose mode
1 | ffmpeg -v |
Get
[debug] Encodings: locale US-ASCII, fs utf-8, out None, pref US-ASCII
[debug] Python version 2.7.10 (CPython) - Darwin-18.2.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg present, ffprobe present
Run version of ffprobe
1 | ffprobe --version |
Get dylb not found
dyld: Library not loaded: /usr/local/Cellar/ffmpeg/4.1.1/lib/libavdevice.58.dylib
Similar issue https://techglimpse.com/ffprobe-command-error-linux-solution/
Read dylib path https://stackoverflow.com/questions/23777191/dyld-library-not-loaded-when-trying-to-run-fortran-executable-from-objective-c
Issue #177
This is useful to refer to another executable in a running executable in Process
1 | Bundle.main.path(forResource: "ffmpeg", ofType: "")! |
Issue #176
Enable executable
1 | chmod +x executable |
Add executable file to target
Use Process
with correct launchPad
1 | import Foundation |
Issue #175
1 | let process = Process() |
Should be the same as FileManager.default.currentDirectoryPath
Issue #174
Disable vibrancy mode of NSPopover
1 | let popover = NSPopover() |
Issue #173
You might need to flip NSClipView
1 | import AppKit |
Issue #171
1 | var views: NSArray? |
Issue #140
I need to generate QR code in https://github.com/onmyway133/AddressGenerator. Fortunately with CoreImage
filter, it is very easy. Code is in Swift 4
1 | import AppKit |
Issue #131
Here’s how to create NSCollectionView
programatically. We need to embed it inside NScrollView
for scrolling to work. Code is in Swift 4
1 | let layout = NSCollectionViewFlowLayout() |
1 | scrollView = NSScrollView() |
1 | final class Cell: NSCollectionViewItem { |
1 | func collectionView(_ collectionView: NSCollectionView, numberOfItemsInSection section: Int) -> Int { |
1 | func collectionView(_ collectionView: NSCollectionView, didSelectItemsAt indexPaths: Set<IndexPath>) { |
Updated at 2020-05-22 11:48:15
Issue #94
One thing I like about kickstarter-ios is how they use Playground
to quickly protoyping views.
We use Swift Playgrounds for iterative development and styling. Most major screens in the app get a corresponding playground where we can see a wide variety of devices, languages and data in real time.
This way we don’t need Injection or using React Native anymore. Take a look at all the pages https://github.com/kickstarter/ios-oss/tree/master/Kickstarter-iOS.playground/Pages
Issue #91
I’m familiar with the whole app structure that Xcode gives me when I’m creating new macOS project, together with Storyboard. The other day I was reading touch-bar-simulator and see how it declares app using only code. See this main.swift
1 | let app = NSApplication.shared |
Issue #86
Today I met a strange problem. After I enter my password, the progress bar runs to the end, and it is stuck there forever. No matter how many times I try to restart.
I finally need to go to Recovery mode by pressing Cmd+R
at start up. I then select Get Help Online
to open Safari. Strangely enough I wasn’t connected to Internet
After select the wifi icon on the status bar to connect internet, I then restart and can login again. It seems that macOS is checking for something before allowing user to login
Issue #34
In an iOS project, we often see this in AppDelegate
1 |
|
But in a Cocoa project, we see this instead
1 |
|
In this case the param is of type NSNotification
Reading Cocoa Core Competencies - Delegation
The delegate of most Cocoa framework classes is automatically registered as an observer of notifications posted by the delegating object. The delegate need only implement a notification method declared by the framework class to receive a particular notification message. Following the example above, a window object posts an NSWindowWillCloseNotification to observers but sends a windowShouldClose: message to its delegate.
So the pattern is that the delegate should strip the NS
and Notification
, like NSWindowWillCloseNotification
to windowShouldClose:
Issue #23
Returns whether the constraints impacting the layout of the view incompletely specify the location of the view.
This method randomly changes the frame of a view with an ambiguous layout between its different valid values, causing the view to move in the interface. This makes it easy to visually identify what the valid frames are and may enable the developer to discern what constraints need to be added to the layout to fully specify a location for the view.
This returns a string describing the whole view tree which tells you when a view has an ambiguous layout.
The name that identifies the constraint.
https://forums.developer.apple.com/thread/63811
Issue #6
I like writing with markdown, it gives me comfortable experience with complete control over what I want to write.
I recommend vmd which renders exactly as GitHub. vmd
is for rendering only, you need an editor to write, I use Sublime Text
because it opens very fast
I also recommend using spectacle to easily split and organize windows