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
This preserves aspect, fills it up, and then clips overflows: | |
self.viewTitleImageView.contentMode = UIViewContentModeScaleAspectFill; | |
[self.viewTitleImageView setClipsToBounds:YES]; |
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
UILabel.appearance().defaultFont = UIFont.systemFont(ofSize: 15/*Any Value*/, weight: UIFontWeightThin) | |
extension UILabel{ | |
dynamic var defaultFont: UIFont? { | |
get { return self.font } | |
set { | |
let sizeOfOldFont = self.font.pointSize | |
let fontNameOfNewFont = newValue?.fontName | |
self.font = UIFont(name: fontNameOfNewFont!, size: sizeOfOldFont) | |
} |
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
enum ArrayError: Error { | |
case OutOfBounds(min: Int, max: Int) | |
} | |
extension Array { | |
mutating func set(index:Int, value: Element) throws { | |
guard self.indices.contains(index) else { |
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
/* | |
check if the password lenght more than or equal 8 | |
and have lowercase , uppercase ,decimalDigits and special characters like !@#$%^&*()_-+ is optional | |
Why i not use regular expression ? | |
Because it's difficult to support reserved characters in regular expression syntax. | |
*/ | |
func isValidated(_ password: String) -> Bool { | |
var lowerCaseLetter: Bool = false |
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
/* | |
Thanks for @olebegemann | |
code of keypath from this link | |
https://oleb.net/blog/2017/01/dictionary-key-paths/ | |
*/ | |
struct KeyPath { | |
var segments: [String] | |
var isEmpty: Bool { return segments.isEmpty } |
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
#!/bin/sh | |
export PATH=/opt/local/bin/:/opt/local/sbin:$PATH:/usr/local/bin: | |
convertPath=`which convert` | |
gsPath=`which gs` | |
if [[ ! -f ${convertPath} || -z ${convertPath} ]]; then | |
convertValidation=true; | |
else | |
convertValidation=false; |
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
pod cache clean Realm | |
pod cache clean RealmSwift | |
pod deintegrate || rm -rf Pods | |
pod install --verbose | |
rm -rf ~/Library/Developer/Xcode/DerivedData |
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
//I get this code from Arek Holko artival https://holko.pl/2017/06/26/checking-uiviewcontroller-deallocation/ | |
import UIKit | |
extension UIViewController { | |
public func dch_checkDeallocation(afterDelay delay: TimeInterval = 2.0) { | |
let rootParentViewController = dch_rootParentViewController | |
// We don’t check `isBeingDismissed` simply on this view controller because it’s common | |
// to wrap a view controller in another view controller (e.g. in UINavigationController) | |
// and present the wrapping view controller instead. |
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 swizzling: (AnyClass, Selector, Selector) -> Void = { forClass, originalSelector, swizzledSelector in | |
guard | |
let originalMethod = class_getInstanceMethod(forClass, originalSelector), | |
let swizzledMethod = class_getInstanceMethod(forClass, swizzledSelector) | |
else { return } | |
method_exchangeImplementations(originalMethod, swizzledMethod) | |
} |
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 UIViewController { | |
static let classInit: Void = { | |
let originalSelector = #selector(viewDidDisappear) | |
let swizzledSelector = #selector(swizzled_viewDidDisappear) | |
swizzling(UIViewController.self, originalSelector, swizzledSelector) | |
}() | |
OlderNewer