Last active
January 9, 2016 22:45
-
-
Save ericdke/64da8512aaa72a87f084 to your computer and use it in GitHub Desktop.
Swift OSX: recently opened applications (only OS X 10.9 and 10.10)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let listBase = LSSharedFileListCreate(kCFAllocatorDefault, kLSSharedFileListRecentApplicationItems.takeUnretainedValue(), NSMutableDictionary()) | |
| let list = listBase.takeUnretainedValue() as LSSharedFileListRef | |
| var seed:UInt32 = 0 | |
| let itemsCF = LSSharedFileListCopySnapshot(list, &seed) | |
| if let items = itemsCF.takeUnretainedValue() as? [LSSharedFileListItemRef] { | |
| for item in items { | |
| let listItemURL = LSSharedFileListItemCopyResolvedURL(item, 0, nil) | |
| let urlBase = listItemURL.takeUnretainedValue() | |
| let url = urlBase as NSURL | |
| let listItemName = LSSharedFileListItemCopyDisplayName(item) | |
| let name = listItemName.takeUnretainedValue() as String | |
| println(url) | |
| println(name) // localized | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment