This file contains hidden or 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
1. Open Terminal | |
2. cd to your Xcode project | |
3. Execute the following when inside your target project: | |
find . -name "*.swift" -print0 | xargs -0 wc -l |
This file contains hidden or 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 UIView { | |
var leftAnchor: NSLayoutXAxisAnchor { | |
return iOS11NAbove ? safeAreaLayoutGuide.leftAnchor : self.leftAnchor | |
} | |
var rightAnchor: NSLayoutXAxisAnchor { | |
return iOS11NAbove ? safeAreaLayoutGuide.rightAnchor : self.rightAnchor | |
} | |
var topAnchor: NSLayoutYAxisAnchor { | |
return iOS11NAbove ? safeAreaLayoutGuide.topAnchor : self.topAnchor |
This file contains hidden or 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
target 'Thrift' || 'ThriftConnection' | |
do pods end | |
def pods | |
pod 'Synchronized', '~> 4.0' | |
pod 'SwiftyBeaver' | |
pod 'BlueSSLService' | |
end | |
This file contains hidden or 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
3rd Party Dependency Tool commands | |
Cocoapod: | |
1)Pod initialization | |
Command: pod init | |
2)Pod installation or updation | |
Command: pod install or pod update | |
Carthage: | |
1)Carthage initialization |
This file contains hidden or 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
//Using C function in Swift | |
var numbers = [50,4,13,2,1] | |
func quickSort(input: inout [Int]) { | |
qsort(&input, input.count, MemoryLayout<Int>.size) { (l,r) -> Int32 in | |
if let left = l?.assumingMemoryBound(to: Int.self), | |
let right = r?.assumingMemoryBound(to: Int.self) { | |
if left.pointee < right.pointee { | |
return -1 | |
}else if left.pointee == right.pointee { |
This file contains hidden or 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
// Credit: Hooman Mehr via swift-evolution | |
// https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20171113/041314.html | |
import Foundation | |
public enum Result<Value> { | |
case success(Value) | |
case failure(Error) | |
public init(_ value: Value) { self = .success(value) } |
This file contains hidden or 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
Refer: https://stackoverflow.com/questions/34230191/added-pod-files-and-pushed-how-to-undo-how-to-use-gitignore-in-xcode-github/34239746 | |
That's correct, you need to add the Pods directory to your .gitignore | |
1) Remove your files from your github repository: | |
git rm -r Pods/ | |
and don't forget to commit and push |
This file contains hidden or 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 DateFormatter { | |
class func formatter(dateFormat: String = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", | |
timeZone: TimeZone? = TimeZone(abbreviation: "UTC")) -> DateFormatter? { | |
if let timeZone = timeZone { | |
return self.init(dateFormat: dateFormat, timeZone: timeZone) | |
} | |
return nil | |
} | |
convenience init(dateFormat: String, timeZone: TimeZone) { | |
self.init() |
This file contains hidden or 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
/* Error Handling in Swift*/ | |
struct MyError: Error { | |
private let possibleErrors: [Int:String] = { | |
return [ | |
200: "Success", | |
403: "Forbidden", | |
404: "Not Found", | |
500: "Internal Server Error", | |
-999: "Make use of this Error code with your own usage"] |
This file contains hidden or 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 | |
import UIKit | |
struct StoryboardIdentifiers { | |
static let ViewController1 = "ViewController1" | |
static let ViewController2 = "ViewController2" | |
static let ViewController3 = "ViewController3" | |
static let ViewController4 = "ViewController4" | |
static let ViewController5 = "ViewController5" | |
static let ViewController6 = "ViewController6" |
NewerOlder