Skip to content

Instantly share code, notes, and snippets.

View ManWithBear's full-sized avatar
🐻
Bear with it

Denis Bogomolov ManWithBear

🐻
Bear with it
View GitHub Profile
@ManWithBear
ManWithBear / NSLayoutConstraints debug
Created October 18, 2016 11:48
Help to understand layout issues
1. Symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints.
2. Add debug command:
- ObjC: po [[UIWindow keyWindow] _autolayoutTrace]
- Swift: expr -l objc++ -O -- [[UIWindow keyWindow] _autolayoutTrace]
3. Colorfy bad views:
expr ((UIView *)0x7f9ea3d43410).backgroundColor = [UIColor redColor]
@ManWithBear
ManWithBear / String2Enum.swift
Last active November 14, 2016 11:32 — forked from jckarter/gist:53fcd4046e2857bd315b
Optional chaining raw value conversion
extension String {
func toEnum<Enum: RawRepresentable where Enum.RawValue == String>() -> Enum? {
return Enum(rawValue: self)
}
}
enum Segue: String {
case Foo
case Bar
}
@ManWithBear
ManWithBear / UIResponder.swift
Last active July 8, 2019 11:08
Fast way to get firstResponder
import UIKit
private weak var _currentFirstResponder: UIResponder? = nil
extension UIResponder {
class func mwb_firstResponder() -> UIResponder? {
_currentFirstResponder = nil
// If you trying send action to nil, it will automatically called on first responder
UIApplication.shared.sendAction(#selector(mwb_findFirstResponder), to: nil, from: nil, for: nil)
return _currentFirstResponder
@ManWithBear
ManWithBear / gitflow.txt
Created May 12, 2016 08:08
Git flow model
git checkout develop
git merge --squash feature/...
git commit -am '#issue comment'
git push origin develop
git branch -D feature/...
git push origin :feature/...
In result flow like:
* <1234567> 2016-05-06 [dev1] (HEAD, origin/develop, develop) version bump
| * <1234567> 2016-05-06 [dev1] (tag: 1.52, master, origin/master) Merge branch 'develop'