Skip to content

Instantly share code, notes, and snippets.

Yasmin Benatti yabenatti

Block or report user

Report or block yabenatti

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yabenatti
yabenatti / uFeature.podspec
Created Mar 7, 2019
Example of a podspec
View uFeature.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'
View HelloWorldObjc.m
- (NSString *)getName {
return @"Yasmin Benatti";
}
- (void)helloWorld {
NSLog(@"Hello %@", [self getName]);
}
[self helloWorld];
View helloWorldSwift.swift
func getName() -> String {
return "Yasmin Benatti"
}
func helloWorld() {
print("Hello " + getName())
}
helloWorld()
View TableViewTutorial03.swift
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
}
View TableViewTutorial02.swift
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)
View TableViewTutorial01.swift
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.
View DelegateTutorialSecondViewController.swift
import UIKit
protocol SecondViewControllerProtocol {
func didDoSomethingOnSecondViewController(message: String)
}
class SecondViewController: UIViewController {
//MARK: - Variables
var delegate: SecondViewControllerProtocol?
View DelegateTutorialFirstViewController.swift
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
}
View UIAlertControllerSelectedAnimal.swift
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)
}
View HideKeyboard.swift
// MARK: - Keyboard
@IBAction func hideKeyboard(_ sender: Any) {
self.view.endEditing(true)
}
You can’t perform that action at this time.