Skip to content

Instantly share code, notes, and snippets.

View DanielStormApps's full-sized avatar
👨‍💻
Looking at your code

Daniel Storm DanielStormApps

👨‍💻
Looking at your code
View GitHub Profile
// The SwiftUI Lab
// Website: https://swiftui-lab.com
// Article: https://swiftui-lab.com/alignment-guides
import SwiftUI
class Model: ObservableObject {
@Published var minimumContainer = true
@Published var extendedTouchBar = false
@Published var twoPhases = true
@Koze
Koze / CaseIterable+Index.swift
Last active July 16, 2020 10:17
index of CaseIterable enum
/*
Copyright (c) 2018 Kazume Koze
Released under the MIT license
https://opensource.org/licenses/mit-license.php
*/
//
// CaseIterable+Index.swift
//
//
@DanielStormApps
DanielStormApps / EmailValidator.swift
Last active March 16, 2021 14:22 — forked from darthpelo/EmailValidator.swift
This regular expression is adapted from a version at regular-expressions.info and is a complete verification of RFC 2822. Source: http://www.cocoawithlove.com/2009/06/verifying-that-string-is-email-address.html. Dedicate article: https://medium.com/@darthpelo/email-validation-in-swift-3-0-acfebe4d879a
extension String {
/// Checks if the `String` is a valid email address.
/// ````
/// // Example
/// "name@email.com".isValidEmailAddress() // true
/// "name(at)email(dot)com".isValidEmailAddress() // false
/// "name@email".isValidEmailAddress() // false
/// "name@.com".isValidEmailAddress() // false
/// "name.com".isValidEmailAddress() // false
@cprovatas
cprovatas / Data+PrettyPrint.swift
Created May 23, 2018 15:52
Pretty print JSON string from Data in Swift 4.1 (especially useful printing to Xcode console)
import Foundation
extension Data {
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription
guard let object = try? JSONSerialization.jsonObject(with: self, options: []),
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]),
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil }
return prettyPrintedString
}
@fousa
fousa / FairPlayer.swift
Last active June 1, 2023 12:28
Integrate HLS with FairPlay.
class FairPlayer: AVPlayer {
private let queue = DispatchQueue(label: "com.icapps.fairplay.queue")
func play(asset: AVURLAsset) {
// Set the resource loader delegate to this class. The `resourceLoader`'s delegate will be
// triggered when FairPlay handling is required.
asset.resourceLoader.setDelegate(self, queue: queue)
// Load the asset in the player.
@skabber
skabber / exportOptions.plist
Last active April 14, 2024 20:47
Export Options Plist Example
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>app-store</string>
<key>teamID</key>
<string>XXXXXXXXXX</string>
<key>uploadBitcode</key>
<true/>
import Foundation
import UIKit
public class Checkmark: UIView {
// MARK: Public variables
public var initialLayerColor: UIColor = UIColor.blue {
didSet {
initialLayer.strokeColor = initialLayerColor.cgColor
}
@DejanEnspyra
DejanEnspyra / Obfuscator.swift
Created May 31, 2017 17:51
Obfuscation of hard-coded security-sensitive strings.
//
// Obfuscator.swift
//
// Created by Dejan Atanasov on 2017-05-31.
//
import Foundation
class Obfuscator: AnyObject {

Note

Apple will reject apps that are using private url schemes (Ugh, Apple....) if they are pretty much obvius. Some apps are rejected and others are not, so, be aware of this issue before implementing any of those URL's in your app as a feature.

Updates

  • [UPDATE 4] iOS 10 update: apparently settings now can be reached using App-Pref instead of prefs
  • [UPDATE 3] For now you just can use url schemes to open your apps's settings with Swift 3.0 (Xcode 8). I'll keep you informed when OS preferences can be reached
  • [UPDATE 2] The openURL() method of UIApplication is now deprecated. You should use application(_:open:options:) instead
  • [UPDATE 1] Not yet tested in iOS 10. It will fail because of policies changes in URL scheme handling.
@ryanrey
ryanrey / Font.swift
Created May 8, 2017 03:41
UIFont Extension
typealias Font = UIFont
public extension Font {
convenience init(_ family: FontFamily = .system, size: CGFloat = 17.0, weight: FontWeight = FontWeight.regular) {
let descriptor: UIFontDescriptor
if family == .system {
descriptor = UIFont.systemFont(ofSize: size, weight: weight.value).fontDescriptor
} else {
var attributes: [String: AnyObject] = [:]
attributes[UIFontDescriptorNameAttribute] = family.name as AnyObject