-
swiftc
invokes sub-commands, so you shouldn't runlldb
on theswiftc
command itself. You can add the-###
option toswiftc
to see the underlying sub-commands. Pick the correct sub-command, then runlldb -- <command>
. -
Usually, we want the first command, so run something like:
lldb -- `swiftc file.swift | head -n 1`
-
Use
--one-line r
to run immediately after loading, without having to set breakopints - great for debugging crashes
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 is an alternate responder chain implementation that | |
DOES NOT work in Swift 2.2, but might in a | |
hypothetical future version of Swift. */ | |
protocol Command { | |
} | |
protocol ResponderChainable { | |
var nextResponder: ResponderChainable? { get } | |
} |
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
/* A responder chain implementation for a hypothetical pure-Swift | |
* equivalent for UIKit. | |
* More info at: http://roopc.net/posts/2016/swifty-responder-chain/ | |
*/ | |
/* A responder is something that has an optional next responder, | |
so that we can have a chain of responders. */ | |
protocol Responder { | |
var nextResponder: Responder? { get } |
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
protocol Feed: Equatable { | |
var url: String { get } | |
} | |
func ==<T: Feed>(lhs: T, rhs: T) -> Bool { | |
return (lhs.url == rhs.url) | |
} | |
protocol Folder { | |
typealias FeedType: Feed |
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
/* | |
AutoLayoutHelper.swift is published under the MIT License. | |
Copyright (C) 2014-15, Roopesh Chander http://roopc.net/ | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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
/* | |
ObservationHelper.swift is published under the MIT License. | |
Copyright (C) 2014-15, Roopesh Chander http://roopc.net/ | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
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
#!/usr/bin/perl -w | |
use strict; | |
# Makefile generator for quick compilation of Swift projects | |
# By: Roopesh Chander | |
# Thanks: Andy Matuschak | |
# Works only for swift-only projects. | |
# Usage: | |
# > perl makemake.pl | |
# > make |
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 Array { | |
var unsafePointerToElements: UnsafePointer<T> { | |
return self.withUnsafePointerToElements { return $0 } | |
} | |
subscript (index: Int) -> T { | |
get { | |
let ptr = self.unsafePointerToElements | |
return ptr[index] | |
} | |
set(rhs) { |
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 Array { | |
func sharesStorageWith(other: Array<T>) -> Bool { | |
let thisPtr: UnsafePointer<T> = self.withUnsafePointerToElements { return $0 } | |
let otherPtr: UnsafePointer<T> = other.withUnsafePointerToElements { return $0 } | |
return (thisPtr == otherPtr) | |
} | |
} | |
var a1: Array<Int> = [10, 11] | |
a1.append(20) |
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
class MyClass { | |
var value: Int | |
init(value v: Int) { value = v } | |
} | |
var instanceOfMyClass = MyClass(value: 42) | |
var assignedInstance2 = instanceOfMyClass | |
assignedInstance2.value = 2 // Change the copied instance | |
instanceOfMyClass.value // 2: Original is also changed |
NewerOlder