Skip to content

Instantly share code, notes, and snippets.

View hartlco's full-sized avatar

Martin Hartl hartlco

View GitHub Profile
@hartlco
hartlco / release.yml
Created March 7, 2021 14:21
Release private Pods using GitHub Actions
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version (i.e. 1.1.3)'
required: true
name:
description: 'Name of the Version'
@propertyWrapper
struct UserDefault<T> {
let key: String
let defaultValue: T
let userDefaults: UserDefaults
init(_ key: String,
defaultValue: T,
userDefaults: UserDefaults) {
self.key = key

Keybase proof

I hereby claim:

  • I am hartlco on github.
  • I am hartlco (https://keybase.io/hartlco) on keybase.
  • I have a public key whose fingerprint is B3A4 35FF 9D40 E298 DE76 8598 5089 83EA 8843 A189

To claim this, I am signing this object:

struct User {
let id: Int
let name: String
let email: String?
}
extension User: JSONDecodable {
static func create(id: Int, name: String, email: String?) -> User {
return User(id: id, name: name, email: email)
}
@hartlco
hartlco / HighlightFirstLineStatic.swift
Created May 21, 2015 08:43
HighlightFirstLineStatic.swift
override func viewDidLoad() {
...
self.highlightFirstLineInTextView(self.textView)
}
private func highlightFirstLineInTextView(textView: UITextView) {
let textAsNSString = textView.text as NSString
let lineBreakRange = textAsNSString.rangeOfString("\n")
let newAttributedText = NSMutableAttributedString(attributedString: textView.attributedText)
let boldRange: NSRange
class MyViewController {
// Standard view controller stuff here
}
extension MyViewController: UITableViewDelegate {
// Table view delegate methods here
}
extension MyViewController: UITextFieldDelegate {
// Text field delegate methods here
var textLabel: UILabel?
// later...
if let textLabel = textLabel {
// do something with textLabel, which is now unwrapped
}
//
// UINavigationBar+CustomHeight.h
//
// Copyright (c) 2014 Maciej Swic
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
@hartlco
hartlco / AppstoreReceiptObtain.swift
Last active August 29, 2015 14:06
Obtaining the Appstore receipt for iOS Apps
class AppStoreReceiptObtainer: NSObject, SKRequestDelegate {
let receiptUrl = NSBundle.mainBundle().appStoreReceiptURL
func obtainReceipt() {
var fileExists = NSFileManager.defaultManager().fileExistsAtPath(receiptUrl.path!)
if fileExists {
println("Appstore Receipt already exists")
return;
@hartlco
hartlco / gist:10838788
Created April 16, 2014 09:15
keybase.md
### Keybase proof
I hereby claim:
* I am mhaddl on github.
* I am mhaddl (https://keybase.io/mhaddl) on keybase.
* I have a public key whose fingerprint is 03B8 D9BE F33B 873A 14AA 347D 0A25 C80A 3369 4945
To claim this, I am signing this object: