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
| //Chamando a funcão GET | |
| getRequest(url: url){ | |
| (resultado, erro) in | |
| if(resultado != nil) { | |
| //O resultado aqui vem como Opcional | |
| print("Sua requisicao foi realizada com sucesso: \n \(resultado)") | |
| } else { | |
| print("A requisicao nao funcionou") | |
| } | |
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
| func getRequest(url: String, | |
| completion: @escaping ([String: Any]?, Error?) -> Void){ | |
| } |
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
| func getRequest(url: String, | |
| completion: @escaping ([String: Any]?, Error?) -> Void){ | |
| //URL válida | |
| guard let URL = URL(string: url) else { | |
| completion(nil, nil) | |
| return | |
| } | |
| } |
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
| func getRequest(url: String, | |
| completion: @escaping ([String: Any]?, Error?) -> Void){ | |
| //URL válida | |
| guard let URL = URL(string: url) else { | |
| completion(nil, nil) | |
| return | |
| } | |
| //Cria a representacão da requisição | |
| let request = NSMutableURLRequest(url: URL) |
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
| //Não esqueca de importar o Foundation | |
| func getRequest(url: String, | |
| completion: @escaping ([String: Any]?, Error?) -> Void){ | |
| //URL válida | |
| guard let URL = URL(string: url) else { | |
| completion(nil, nil) | |
| return | |
| } | |
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 { | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| let path = UIBezierPath() | |
| path.move(to: CGPoint(x: 50, y: 100)) |
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 | |
| protocol CompactadorStrategy { | |
| func compactar(mensagem: String) -> String | |
| func descompactar(mensagem: String) -> String | |
| } | |
| class Compactador { | |
| private let strategy:CompactadorStrategy | |
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
| EscolherImagem().selecionadorImagem(self){ imagem in | |
| //Aqui temos a nossa imagem | |
| } |
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 EscolherImagem: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate { | |
| //Instancia o Controle de Seletor de Imagens | |
| var selecionador = UIImagePickerController(); | |
| //Cria um alerta | |
| var alerta = UIAlertController(title: "Escolha uma opção", message: nil, preferredStyle: .actionSheet) | |
| //Cria uma variável do tipo UIViewController |
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 EscolherImagem: NSObject, UIImagePickerControllerDelegate, | |
| UINavigationControllerDelegate { | |
| //Instância o controle do sistema de imagens | |
| var selecionador = UIImagePickerController(); | |
| //Cria um alerta | |
| var alerta = UIAlertController(title: "Escolha uma opção", message: nil, | |
| preferredStyle: .actionSheet) |