This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIColor { | |
class var theme: UIColor { return #colorLiteral(red: 0.4274509804, green: 0.7568627451, blue: 0.6196078431, alpha: 1) } | |
class var notification: UIColor { return #colorLiteral(red: 1, green: 0.4666666667, blue: 0, alpha: 1) } | |
class var negative: UIColor { return #colorLiteral(red: 0.9843137255, green: 0.4588235294, blue: 0.4588235294, alpha: 1) } | |
class var darkBackground: UIColor { return #colorLiteral(red: 0.1725490196, green: 0.1725490196, blue: 0.1725490196, alpha: 1) } | |
class var darkLightBackground: UIColor { return #colorLiteral(red: 0.3401621282, green: 0.3401621282, blue: 0.3401621282, alpha: 1) } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIColor { | |
class var theme: UIColor { return #colorLiteral(red: 0.4274509804, green: 0.7568627451, blue: 0.6196078431, alpha: 1) } | |
// 別解1(推奨) | |
struct MyApp { | |
static var theme: UIColor { return #colorLiteral(red: 0.4274509804, green: 0.7568627451, blue: 0.6196078431, alpha: 1) } | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIColor { | |
struct JoinUs { | |
private init() {} | |
/** #6DC19E */ | |
static let theme = #colorLiteral(red: 0.4274509804, green: 0.7568627451, blue: 0.6196078431, alpha: 1) | |
/** #FF7700 */ | |
static let notification = #colorLiteral(red: 1, green: 0.4666666667, blue: 0, alpha: 1) | |
/** #FB7575 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String.CharacterView { | |
subscript(sequentialAccess i: Int) -> Character { | |
let index = self.index(startIndex, offsetBy: i) | |
return self[index] | |
} | |
subscript(sequentialAccess range: Range<Int>) -> String.CharacterView { | |
let start = self.index(startIndex, offsetBy: range.lowerBound) | |
let end = self.index(start, offsetBy: range.count) | |
return self[start..<end] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String.CharacterView { | |
func read(_ i: Int) -> Character { | |
let index = self.index(startIndex, offsetBy: i) | |
return self[index] | |
} | |
func read(_ range: Range<Int>) -> String.CharacterView { | |
let start = self.index(startIndex, offsetBy: range.lowerBound) | |
let end = self.index(start, offsetBy: range.count) | |
return self[start..<end] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let s = "Café du 🌍" | |
let si = s.startIndex | |
let ci = s.characters.startIndex | |
si == ci // true | |
let si2 = s.index(si, offsetBy: 3) | |
let ci2 = s.characters.index(ci, offsetBy: 3) | |
si2 == ci2 // true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String: BidirectionalCollection, RangeReplaceableCollection {} | |
extension String { | |
public mutating func removeFirst(_ n: Int) { | |
characters.removeFirst(n) | |
} | |
public mutating func removeLast(_ n: Int) { | |
characters.removeLast(n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// まずString.CharacterViewにメソッド定義 | |
extension String.CharacterView { | |
public subscript(sequentialAccess range: Range<Int>) -> String.CharacterView { | |
let lower = range.lowerBound | |
let startIndex = index(self.startIndex, offsetBy: lower) | |
let endIndex = index(startIndex, offsetBy: range.count) | |
return self[startIndex..<endIndex] | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension String { | |
var capitalizingFirstLetter: String { | |
return String(characters.prefix(1)).capitalized + String(characters.dropFirst()) | |
} | |
} | |
enum MyEnum: String { | |
case fooBar | |
var rawValue: String { return String(describing: self).capitalizingFirstLetter } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"profiles": [ | |
{ | |
"devices": [ | |
{ | |
"identifiers": { | |
"is_keyboard": true, | |
"is_pointing_device": false, | |
"product_id": 272, | |
"vendor_id": 2131 |