Skip to content

Instantly share code, notes, and snippets.

View mwrites's full-sized avatar
🔧

Mathieu mwrites

🔧
View GitHub Profile
func asyncTestWithAssertBlock(block: (XCTestExpectation)->()) {
let expectation = self.expectationWithDescription("test expectation")
block(expectation)
waitForExpectationsWithTimeout(3, handler: nil)
}
func notifTestWithAssertBlock(block: ()-> Void) {
expectationForNotification(Blurbs.BlurbsReadyNotification, object: nil) { _ in
block()
return true
extension UIStoryboard {
static func main() -> UIStoryboard {
return UIStoryboard(name: "Main", bundle: nil)
}
// assuming that name of the class is the identifier
static func controllerOfType<C where C : UIViewController> (type : C.Type) -> C {
let name = String(type)
let vc = UIStoryboard.main().instantiateViewControllerWithIdentifier(name)
# UIPresentation Controlers
https://realm.io/news/slug-jesse-squires-swifty-view-controller-presenters/
Transition > transiting state
Presentation > final state
Presentation hook into the transition API
responsibilities
#file in first sub directory
find . -iname "*.strings" -maxdepth 2
#file with pattern
ls -d *.lproj
#file with pattern recurive
find . *.lproj -type d -print
#directory of file
/Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Resources/IDETextKeyBindingSet.plist
– Delete current line: ctrl + shift + k
– Duplicate current line: ctrl + shift + c
– Insert line below: ctrl + o
– Insert line above: ctrl + shift + o
#Insertion and indentation
<key>Insert New Line Below</key>
ps aux | grep myprocessname | cut -d " " -f 2 | xargs kill
extension Dictionary where Key: StringLiteralConvertible, Value: AnyObject {
var jsonString: String {
return ""
}
}
protocol StringValueExpressible {
var stringValue: String { get }
}
extension String : StringValueExpressible {
var stringValue: String {
get { return self }
}
}
grep -r Answers . --include=\*.{m,swift}
#remove filename
grep -r Answers . --include=\*.{m,swift} -h
#remove white spaces
grep -r Answers . --include=\*.{m,swift} -h | sed -e 's/^[ \t]*//'
enum SvcError: ErrorType {
case Bla
case Blo
case Code(Int)
}
let e: ErrorType = SvcError.Code(3)