Skip to content

Instantly share code, notes, and snippets.

@arohner
Created September 29, 2014 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arohner/566f7811ce30dd295b51 to your computer and use it in GitHub Desktop.
Save arohner/566f7811ce30dd295b51 to your computer and use it in GitHub Desktop.
working with CFArray
public class LaunchAtStartup : NSObject
{
public class func enumerateLaunchItems()
{
let loginItemsRef = LSSharedFileListCreate(nil, kLSSharedFileListSessionLoginItems.takeUnretainedValue(), nil).takeUnretainedValue()
var itemUrl:NSURL?
let loginItems:NSArray = LSSharedFileListCopySnapshot(loginItemsRef, nil).takeUnretainedValue()
logInfo("loginItem count= \(loginItems.count)")
for i in 0..<loginItems.count
{
logInfo("loginItem \(i)")
if let item = loginItems[i] as? LSSharedFileListItem
{
if let itemUrl:Unmanaged<CFURL> = LSSharedFileListItemCopyResolvedURL(item, 0, nil)
{
logInfo("launch item: \(itemUrl.takeUnretainedValue())")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment