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
View MiniCursoIFSPSwiftClass.swift
class Animal {
let name: String
let image: String
init (name: String, image: String) {
self.name = name
self.image = image
}
}
@yabenatti
yabenatti / MiniCursoIFSPSwiftStruct.swift
Created Nov 10, 2017
MiniCursoIFSPSwiftStructAsNamespace
View MiniCursoIFSPSwiftStruct.swift
struct Colors {
private init () {}
static let lightSalmonPink : UIColor! = UIColor(red: 248/255, green: 153/255, blue: 157/255, alpha: 1)
static let lightPurpleUbe : UIColor! = UIColor(red: 125/255, green: 122/255, blue: 188/255, alpha: 1)
static let darkGray : UIColor! = UIColor(red: 132/255, green: 146/255, blue: 166/255, alpha: 1)
}
View MiniCursoIFSPSwiftEnum.swift
enum Errors : Int {
case Unexpected = -1
case NoInternet = 1
case InvalidToken = 2
}
@yabenatti
yabenatti / MiniCursoIFSPSwiftFunctions.swift
Last active Nov 10, 2017
MiniCursoIFSPSwiftFunctions
View MiniCursoIFSPSwiftFunctions.swift
//Regular function
func fillScreen() {
if let animal = self.selectedAnimal {
self.animalImageView.image = UIImage.init(named: animal.image)
self.animalNameLabel.text = animal.name.uppercased()
}
}
//Function with alias on parameter
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
@yabenatti
yabenatti / MiniCursoIFSPSwiftTableViewDataSource.swift
Created Nov 10, 2017
MiniCursoIFSPSwiftTableViewDataSource
View MiniCursoIFSPSwiftTableViewDataSource.swift
extension HomeViewController : UITableViewDataSource {
//Métodos obrigatórios
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.animalsArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: homeCellIndentifier, for: indexPath) as? HomeTableViewCell else {
fatalError("Cannot create Home Table View Cell")
}
@yabenatti
yabenatti / MiniCursoIFSPSwiftTableViewRegisterCells.swift
Created Nov 10, 2017
MiniCursoIFSPSwiftTableViewRegisterCells
View MiniCursoIFSPSwiftTableViewRegisterCells.swift
override func viewDidLoad() {
super.viewDidLoad()
//TableView
self.tableView.delegate = self
self.tableView.dataSource = self
self.tableView.register(UITableViewCell.classForCoder(), forCellReuseIdentifier: "cell")
self.tableView.register(HomeTableViewCell.classForCoder(), forCellReuseIdentifier: homeCellIndentifier)
self.tableView.register(UINib(nibName:"HomeTableViewCell", bundle: nil), forCellReuseIdentifier: homeCellIndentifier)
}
View MiniCursoIFSPSwiftSegue.swift
// MARK: - Navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "HomeToDetailSegue" {
if let vc = segue.destination as? DetailViewController {
vc.delegate = self
if let animal = sender as? Animal {
vc.selectedAnimal = animal
}
}
@yabenatti
yabenatti / MiniCursoIFSPSwiftSegueProgramaticamente.swift
Created Nov 10, 2017
MiniCursoIFSPSwiftSegueProgramaticamente
View MiniCursoIFSPSwiftSegueProgramaticamente.swift
// MARK: - Table View
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let animal = self.animalsArray[indexPath.row]
//programaticamente
let storyboard = UIStoryboard(name: "Home", bundle: nil)
if let vc = storyboard.instantiateViewController(withIdentifier: "DetailViewControllerID") as? DetailViewController {
View CustomView.swift
import UIKit
@IBDesignable
class CustomView: UIView {
// MARK: - IBOutlets
@IBOutlet weak var centerImageView: UIImageView!
// MARK: - Init Methods
View BarButtonItem.swift
self.navigationItem.setRightBarButton(UIBarButtonItem(barButtonSystemItem: .save, target: self, action: #selector(saveProfile)), animated: true)
You can’t perform that action at this time.