Skip to content

Instantly share code, notes, and snippets.

View ashleymills's full-sized avatar

Ashley Mills ashleymills

View GitHub Profile
@ashleymills
ashleymills / ContentView.swift
Created February 24, 2020 12:27
A solution to SwiftUI Challenge #3: Tab Selection (https://twitter.com/objcio/status/1230145263202758658)
struct TabRectsKey: PreferenceKey {
static var defaultValue: [Int: CGRect] = [:]
static func reduce(value: inout [Int : CGRect], nextValue: () -> [Int : CGRect]) {
value.merge(nextValue(), uniquingKeysWith: { r1, r2 in r1 })
}
}
struct TabBar: View {
var items: [(Image, Text)]
@State var selectedIndex: Int = 0
@ashleymills
ashleymills / UIApplication+AppVersion
Created June 18, 2015 13:24
UIApplication category to get app version / build
@implementation UIApplication (AppVersion)
+ (NSString *) appVersion
{
return [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"];
}
+ (NSString *) build
{
return [[NSBundle mainBundle] objectForInfoDictionaryKey: (NSString *)kCFBundleVersionKey];
@ashleymills
ashleymills / UIApplication+AppVersion.swift
Last active April 27, 2022 14:49
UIApplication extension to get app version / build
extension UIApplication {
class func appVersion() -> String {
return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
}
class func appBuild() -> String {
return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
}
@ashleymills
ashleymills / WiktionaryFetcher.swift
Last active August 29, 2015 14:14
Fetch all lower case English language words from Wiktionary
import Foundation
extension String {
func stringsBetween(fromTag: String, and toTag: String) -> [String]? {
let fromTagLen = countElements(fromTag)
let toTagLen = countElements(toTag)
var strings: [String]?