Skip to content

Instantly share code, notes, and snippets.

//: A UIKit based Playground for presenting user interface
import PlaygroundSupport
import UIKit
class MyViewController: UIViewController {
let button1 = UIButton()
let button2 = UIButton()
let button3 = UIButton()
let button4 = UIButton()
@krummler
krummler / String+EmojiCheck.swift
Last active September 3, 2024 11:40
Emoji Checking for Swift 5.0 and up
import Foundation
extension Character {
/// A simple emoji is one scalar and presented to the user as an Emoji
var isSimpleEmoji: Bool {
return unicodeScalars.count == 1 && unicodeScalars.first?.properties.isEmojiPresentation ?? false
}
/// Checks if the scalars will be merged into and emoji
var isCombinedIntoEmoji: Bool {
@krummler
krummler / String+CheckEmoji.swift
Last active September 19, 2024 14:13
Emoji checking, with some legacy code
import Foundation
extension UnicodeScalar {
/// Note: This method is part of Swift 5, so you can omit this.
/// See: https://developer.apple.com/documentation/swift/unicode/scalar
var isEmoji: Bool {
switch value {
case 0x1F600...0x1F64F, // Emoticons
0x1F300...0x1F5FF, // Misc Symbols and Pictographs
0x1F680...0x1F6FF, // Transport and Map