Skip to content

Instantly share code, notes, and snippets.

import UIKit
@IBDesignable
class SpinnerView : UIView {
override var layer: CAShapeLayer {
get {
return super.layer as! CAShapeLayer
}
}
//: Playground - noun: a place where people can play
import UIKit
import AVFoundation
// keep it running forever so it plays audio
import XCPlayground
XCPSetExecutionShouldContinueIndefinitely(true)
class AVPlayerTest {

Aligning images

This is a guide for aligning images.

See the full Advanced Markdown doc for more tips and tricks

left alignment

@fzwo
fzwo / LegacyDocsets.md
Last active May 15, 2024 10:16
Download and view old Apple developer documentation

How to download and view legacy documentation from Apple (no need to sign in to your dev account)

  1. Download the docset index XML.
  2. Find the docset you want (there are some with URL https://apple.com/none.dmg; ignore them - you will find them again further down the file with a working URL).
  3. Download the dmg. It's probably around a gigabyte or so.
  4. "Install" the .pkg file somewhere on your disk. If you don't trust the installer, do it manually:
    1. Find the largest file, named Payload, and extract it using The Unarchiver.
    2. This creates a new, even larger file, probably named Payload-1.
    3. Extract Payload-1 using The Unarchiver.
  5. After many minutes of extracting, we have our .docset file.
@martinpi
martinpi / AutocompleteView.swift
Created November 5, 2018 13:41
An autocomplete popup for text entry. Ported to Swift from this example: https://github.com/danjonweb/NCRAutocompleteTextView
//
// AutocompleteView.swift
//
// Originally created by Daniel Weber on 9/28/14.
// Copyright (c) 2014 Null Creature. All rights reserved.
// Ported to Swift by Martin Pichlmair 2018
//
import Cocoa
@4np
4np / HowTo use xcconfig or plist with SPM.md
Last active January 25, 2024 22:20
How to use a .xcconfig file and a .plist with a Swift Package Manager based project.

How to use a .xcconfig file and a .plist file with SPM

Worth a read for some more context.

Create a Package.xcconfig file

Create the file in the root of the project (where your Package.swift file lives as well), and use the following contents:

/// Package.xcconfig
//
// UserDefaults+PropertyWrapper.swift
// PodliveShared
//
// Created by Stefan Trauth on 18.06.19.
// Copyright © 2019 Stefan Trauth. All rights reserved.
//
import Foundation
@unnamedd
unnamedd / MacEditorTextView.swift
Last active May 26, 2024 17:49
[SwiftUI] MacEditorTextView - A simple and small NSTextView wrapped by SwiftUI.
/**
* MacEditorTextView
* Copyright (c) Thiago Holanda 2020-2021
* https://twitter.com/tholanda
*
* MIT license
*/
import Combine
import SwiftUI
@funkenstrahlen
funkenstrahlen / Calendar.swift
Created May 8, 2020 07:17 — forked from mecid/Calendar.swift
Calendar view in SwiftUI
import SwiftUI
fileprivate extension DateFormatter {
static var month: DateFormatter {
let formatter = DateFormatter()
formatter.dateFormat = "MMMM"
return formatter
}
static var monthAndYear: DateFormatter {
@d4rkd3v1l
d4rkd3v1l / ExpansionHandler.swift
Last active January 31, 2024 02:24
SwiftUI: DisclosureGroup "expansion handler" to only have one group expanded at a time, and automatically hiding the last one, when expanding a new one.
class ExpansionHandler<T: Equatable>: ObservableObject {
@Published private (set) var expandedItem: T?
func isExpanded(_ item: T) -> Binding<Bool> {
return Binding(
get: { item == self.expandedItem },
set: { self.expandedItem = $0 == true ? item : nil }
)
}