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
func grabCity(_ str: String) -> String { | |
// the commented line below (the regex to be exact) gets just the last word! which is wrong, my fault though, i didn't read the challenge corectly! | |
// let regex = try! NSRegularExpression(pattern: "(\\w+)(?!.*\\w)", options: []) | |
// the regex below get every matches in the sentence that is being wrapped in a pair of square brackets. | |
let regex = try! NSRegularExpression(pattern: "(?<=\\[)(.+?)(?=\\])", options: []) | |
// the "result" below is of type NSTextCheckingResult which is an array, since the challenge askes for the last match, and i couldn't get the last match through the regex, i ened up gtting the last match via the "last" item in the array. | |
let result = regex.matches(in: str, options: [], range: NSRange(location: 0, length: str.count)).last | |
/* | |
// from line 11 to 18, is an alternative for getting the matches out of the result array, since it is an array (of type NSTextCheckingResult) you can iterate thtough it (loop though it) | |
// you can use each o |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>destination</key> | |
<string>upload</string> | |
<key>method</key> | |
<string>app-store</string> | |
<key>provisioningProfiles</key> | |
<dict> |
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 | |
/// A validation rule for text input. | |
public enum TextValidationRule { | |
/// Any input is valid, including an empty string. | |
case noRestriction | |
/// The input must not be empty. | |
case nonEmpty | |
/// The enitre input must match a regular expression. A matching substring is not enough. | |
case regularExpression(NSRegularExpression) |
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
//: Playground - noun: a place where people can play | |
// | |
// Created by Pietro Basso on 29/06/2018. | |
// Copyright (c) 2018 Pietro Basso. All rights reserved. | |
// | |
let urls = ["http://youtu.be/NLqAF9hrVbY", | |
"http://www.youtube.com/watch?feature=player_embedded&v=DJjDrajmbIQ", | |
"http://www.youtube.com/watch?v=dQw4w9WgXcQ", | |
"http://www.youtube.com/embed/NLqAF9hrVbY", |
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 Foundation | |
extension UIView { | |
func height(constant: CGFloat) { | |
setConstraint(value: constant, attribute: .height) | |
} | |
func width(constant: CGFloat) { | |
setConstraint(value: constant, attribute: .width) | |
} |
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 UIStackView { | |
func removeAllArrangedSubviews() { | |
let removedSubviews = arrangedSubviews.reduce([]) { (allSubviews, subview) -> [UIView] in | |
self.removeArrangedSubview(subview) | |
return allSubviews + [subview] | |
} |
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 | |
import Firebase | |
import UserNotifications | |
@UIApplicationMain | |
class AppDelegate: UIResponder, UIApplicationDelegate { | |
var window: UIWindow? | |
static var shared: AppDelegate { return UIApplication.shared.delegate as! AppDelegate } |
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
// | |
// Obfuscator.swift | |
// | |
// Created by Dejan Atanasov on 2017-05-31. | |
// | |
import Foundation | |
class Obfuscator: AnyObject { | |
NewerOlder