Skip to content

Instantly share code, notes, and snippets.

@tijme
tijme / UITextViewPlaceholder.swift
Last active May 31, 2024 11:05
The correct way to implement a placeholder in a UITextView (Swift)
//
// UITextViewPlaceholder.swift
// TextViewPlaceholder
//
// Copyright (c) 2017 Tijme Gommers <tijme@finnwea.com>
//
// 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
@pietbrauer
pietbrauer / MD5.swift
Created August 10, 2014 16:59
NSString & NSData to MD5
import Foundation
extension NSData {
func MD5() -> NSString {
let digestLength = Int(CC_MD5_DIGEST_LENGTH)
let md5Buffer = UnsafeMutablePointer<CUnsignedChar>.alloc(digestLength)
CC_MD5(bytes, CC_LONG(length), md5Buffer)
var output = NSMutableString(capacity: Int(CC_MD5_DIGEST_LENGTH * 2))
for i in 0..<digestLength {