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
A typical install of OS X won't create a .bash_profile for you. When you want to run functions from your command line, this is a must-have. | |
Start up Terminal | |
Type "cd ~/" to go to your home folder | |
Type "touch .bash_profile" to create your new file. | |
Edit .bash_profile with your favorite editor (or you can just type "open -e .bash_profile" to open it in TextEdit. | |
Type ". .bash_profile" to reload .bash_profile and update any functions you add. | |
/* |
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
class ApiService { | |
static let sharedInstance = ApiService() | |
let BASE_URL = "https://restcountries.eu" | |
// MARK: - List of countries | |
func countries(_ completion: @escaping(_ result: [Country]?, _ error: Error?) -> Void) { | |
let urlString = BASE_URL + "/rest/v2/all" |
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
sudo xcode-select --reset | |
swift build | |
// The whole process | |
swift package init --type executable | |
swift build | |
swift run <app-name> |
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
override func viewDidLoad() { | |
super.viewDidLoad() | |
let tap = UITapGestureRecognizer(target: self, action: #selector(self.dismissKeyboard)) | |
tap.cancelsTouchesInView = false | |
self.view.addGestureRecognizer(tap) // Dismiss keyboard | |
} | |
func dismissKeyboard(gestureReconizer: UITapGestureRecognizer) { | |
self.view.endEditing(true) |
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 UIKit | |
class ViewController: UIViewController { | |
@IBOutlet weak var textField: UITextField! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let paddingView = UIView(frame: CGRect(x: 0, y: 0, width: 15, height: textField.frame.height)) |
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
// CGPoint converted to NSValue | |
CGPoint point = CGPointMake(9, 9); | |
NSValue *pointObj = [NSValue valueWithCGPoint:point]; | |
// CGSize converted to NSValue | |
CGSize size = CGSizeMake(100, 100); | |
NSValue *sizeObj = [NSValue valueWithCGSize:size]; | |
// CGRect from CGPoint and CGSize converted to NSValue | |
CGRect rect = CGRectMake(point.x, point.y, size.width, size.height); |
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
In console: | |
git config credential.helper | |
You will see: osxkeychain | |
git config credential.helper sourcetree | |
Then if you perform git config credential.helper again | |
You will see: sourcetree |
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
fileprivate var activityIndicator : UIImageView! = UIImageView(image: UIImage.gif(name:"load")) // load.gif file | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.activityIndicator.frame = CGRect(x: 0, y: 0, width: 50, height: 50) | |
self.activityIndicator.contentMode = .scaleAspectFit | |
self.activityIndicator.backgroundColor = UIColor.clear | |
} |
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
let alert = UIAlertController(title: "Some title", message: "Some message", preferredStyle: .alert) | |
alert.addAction(UIAlertAction(title: "Yes", style: .default, handler: { (_) in | |
print("Do some staff") | |
})) | |
alert.addAction(UIAlertAction(title: "No", style: .default, handler: nil)) | |
self.present(alert, animated: true, completion: nil) |