Skip to content

Instantly share code, notes, and snippets.

View yabenatti's full-sized avatar

Yasmin Benatti yabenatti

  • Sweden
View GitHub Profile
@yabenatti
yabenatti / HideKeyboard.swift
Created November 10, 2017 16:20
HideKeyboard
// MARK: - Keyboard
@IBAction func hideKeyboard(_ sender: Any) {
self.view.endEditing(true)
}
@yabenatti
yabenatti / UIAlertControllerSelectedAnimal.swift
Created November 10, 2017 16:21
UIAlertControllerSelectedAnimal
func selectedTheAnimal(animal: Animal) {
let alert = UIAlertController(title: animal.name.uppercased(), message: "Selected the: \(animal.name)", preferredStyle: .alert)
let action = UIAlertAction(title: "OK", style: .cancel, handler: nil);
alert.addAction(action)
self.present(alert, animated: true, completion: nil)
}
@yabenatti
yabenatti / DelegateTutorialFirstViewController.swift
Created November 10, 2017 16:26
DelegateTutorialFirstViewController
import UIKit
class FirstViewController: UIViewController, SecondViewControllerProtocol {
// MARK: - Navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "FirstToSecondSegue" {
if let vc = segue.destination as? SecondViewControllerProtocol {
vc.delegate = self
}
@yabenatti
yabenatti / DelegateTutorialSecondViewController.swift
Created November 10, 2017 16:30
DelegateTutorialSecondViewController
import UIKit
protocol SecondViewControllerProtocol {
func didDoSomethingOnSecondViewController(message: String)
}
class SecondViewController: UIViewController {
//MARK: - Variables
var delegate: SecondViewControllerProtocol?
@yabenatti
yabenatti / TableViewTutorial01.swift
Created November 12, 2017 12:44
TableViewTutorial01
import UIKit
class ViewController: UIViewController {
// MARK: - IBOutlets
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
@yabenatti
yabenatti / TableViewTutorial02.swift
Created November 12, 2017 12:50
TableViewTutorial02
extension ViewController : UITableViewDataSource {
//1 - primeiro método obrigatório
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 10
}
//2 - segundo método obrigatório
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
//3 - crie uma célula com o mesmo identificador de quando registramos a classe
let cell = tableView.dequeueReusableCell(withIdentifier: "tableCell", for: indexPath)
@yabenatti
yabenatti / TableViewTutorial03.swift
Created November 12, 2017 13:01
TableViewTutorial03
extension ViewController : UITableViewDelegate {
//1 - método chamado quando uma linha é selecionada
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
}
//2 - método para definir a altura de cada linha
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 44
}
@yabenatti
yabenatti / helloWorldSwift.swift
Created January 21, 2019 21:13
HelloWorldSwift
func getName() -> String {
return "Yasmin Benatti"
}
func helloWorld() {
print("Hello " + getName())
}
helloWorld()
@yabenatti
yabenatti / HelloWorldObjc.m
Created January 21, 2019 21:19
HelloWorldObjc
- (NSString *)getName {
return @"Yasmin Benatti";
}
- (void)helloWorld {
NSLog(@"Hello %@", [self getName]);
}
[self helloWorld];
@yabenatti
yabenatti / uFeature.podspec
Created March 7, 2019 15:45
Example of a podspec
#
# Be sure to run `pod spec lint uFeature.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#
Pod::Spec.new do |s|
s.name = 'uFeature'