Skip to content

Instantly share code, notes, and snippets.

View alcidesjunior's full-sized avatar
💻
Codando...

Alcides Junior alcidesjunior

💻
Codando...
View GitHub Profile
func setLabel(_ value: NSAttributedString) {
myLabel.attributedText = value
myLabel.lineBreakMode = .byTruncatingTail
}
func setLabel(_ value: NSAttributedString) {
myLabel.attributedText = value
}
private let myLabel: UILabel = {
let label = UILabel()
label.numberOfLines = 1
label.lineBreakMode = .byTruncatingTail
return label
}()
//
// PlayViewModel.swift
// brasileirao
//
// Created by Alcides Junior on 15/03/20.
//
import Foundation
typealias updateClosure = ()->()
@alcidesjunior
alcidesjunior / SceneDelegate.swift
Created March 15, 2020 18:09
Trecho de codigo para iniciar uma viewCode
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
guard let _ = (scene as? UIWindowScene) else { return }
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
let navigation = UINavigationController(rootViewController: PlaysViewController())
let rootView = navigation
//
// MagicConstraints+UIView.swift
// ArctouchQuizChallengeß
//
// Created by Alcides Junior on 13/01/20.
// Copyright © 2020 Alcides Junior. All rights reserved.
//
//USAGE EXAMPLE
startButton
func getAll(_ completion: @escaping (Result<Movie, Error>)->Void){
let url = "\(self.moviesUrl)\(EndPoints.apiKey.rawValue)"
Just.get(url){ (result) in
guard let data = result.content else {return}
do{
let decoder = JSONDecoder()
switch result.statusCode{
case 401:
let errorDecoded = try decoder.decode(GenericErrors.self, from: data)
//
// FavoriteModel.swift
// iCinetop
//
// Created by Alcides Junior on 19/12/19.
// Copyright © 2019 Alcides Junior. All rights reserved.
//
import Foundation
import UIKit
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "movieCell", for: indexPath) as! MovieCollectionViewCell
cell.movieTitle.text = self.movies[indexPath.item].originalTitle
guard let imageUrl = URL(string: "\(EndPoints.baseImageUrl.rawValue)\(self.movies[indexPath.item].posterPath)") else{return cell}
DispatchQueue.main.async {
cell.movieImageView.load(url: imageUrl)
}
return cell
}
//
// MovieCollectionViewCell.swift
// iCinetop
//
// Created by Alcides Junior on 14/12/19.
// Copyright © 2019 Alcides Junior. All rights reserved.
//
import UIKit
import SnapKit