Skip to content

Instantly share code, notes, and snippets.

Avatar

Ashley Mills ashleymills

View GitHub Profile
View ContentView.swift
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 Jun 18, 2015
UIApplication category to get app version / build
View UIApplication+AppVersion
@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 Apr 27, 2022
UIApplication extension to get app version / build
View UIApplication+AppVersion.swift
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 Aug 29, 2015
Fetch all lower case English language words from Wiktionary
View WiktionaryFetcher.swift
import Foundation
extension String {
func stringsBetween(fromTag: String, and toTag: String) -> [String]? {
let fromTagLen = countElements(fromTag)
let toTagLen = countElements(toTag)
var strings: [String]?