Skip to content

Instantly share code, notes, and snippets.

@IBAction func didClickOnExploreButton(_ sender: NSButtonCell)
{
toggleViewStates(state: false)
files = [String:Media]()
switch sender.tag {
case 101:
getFilesFromDoucmentDir(type: .image)
case 102:
getFilesFromDoucmentDir(type: .video)
case 103:
func createDirectory(sourcePath: String, type: MediaType) {
// path to documents directory
let documentDirectoryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first
if let documentDirectoryPath = documentDirectoryPath {
// create the custom folder path
var subDirectoryPath = ""
switch type
{
case .audio:
subDirectoryPath = documentDirectoryPath.appending("/audios")
override func viewDidLoad() {
super.viewDidLoad()
dragDropAreaView.delegate = self
setupView()
}
override func viewDidAppear() {
let flowLayout = NSCollectionViewFlowLayout()
flowLayout.itemSize = NSSize(width: 160.0, height: 120.0)
import Cocoa
class CollectionViewItem: NSCollectionViewItem {
override func viewDidLoad() {
super.viewDidLoad()
view.wantsLayer = true
view.layer?.backgroundColor = NSColor.lightGray.cgColor
}
class DragDropAreView: NSView {
private var fileTypeIsOk = false
private var acceptedFileExtensions = ["jpg","png","doc","docx","pdf","mov","mp4","mp3"]
var delegate: DragDropViewDelegate?
var isReceivingDrag = false {
didSet {
needsDisplay = true
}
enum MediaType
{
case image
case video
case audio
case document
}
struct Media
{