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 ImageDownloader { | |
| var imageCache = NSCache<NSString, UIImage>() | |
| func downloadImage(from url: URL, completion: @escaping (UIImage?) -> Void) { | |
| if let cachedImage = imageCache.object(forKey: url.absoluteString as NSString) { | |
| print("Returning cached image") | |
| completion(cachedImage) |
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
| Struct | Class | ||
|---|---|---|---|
| Type | Value | Reference | |
| Inheritance | X | O | |
| Type Casting | X | O | |
| Deinitializers | X | deinit() | |
| Reference Counting | X | O |
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
| // MARK: - UITableViewDelegate | |
| extension NewsListVC: UITableViewDelegate { | |
| // UISwipe | |
| func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? { | |
| let deleteAction = UIContextualAction(style: .destructive, title: "Delete") { (action, view, completionHandler) in | |
| // example: If name is Luigi, don't delete :) | |
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 | |
| let imageCache = NSCache<AnyObject, AnyObject>() | |
| class CustomImageView: UIImageView { | |
| var task: URLSessionDataTask! | |
| let spinnerView = UIActivityIndicatorView(style: .medium) | |
| func loadImage(from url: URL) { | |
| image = nil |
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
| // MARK: - UITableViewDataSource | |
| extension NewsListVC: UITableViewDataSource { | |
| func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | |
| return amiiboList.count | |
| } | |
| func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | |
| let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) | |
| let amiibo = amiiboList[indexPath.row] |
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 Foundation | |
| import UIKit | |
| class AmiiboCell: UITableViewCell { | |
| let imageV = UIImageView() | |
| var safeArea: UILayoutGuide! | |
| let nameLabel = UILabel() | |
| let gameSeriesLabel = UILabel() | |
| override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { |
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 SwiftUI | |
| struct RotateViewModifier: ViewModifier { | |
| let rotation: Double | |
| func body(content: Content) -> some View { | |
| content | |
| .rotationEffect(Angle(degrees: rotation)) | |
| .offset( | |
| x: rotation != 0 ? UIScreen.main.bounds.width : 0, | |
| y: rotation != 0 ? UIScreen.main.bounds.height : 0) |
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 SwiftUI | |
| struct ButtonViewModifier: ViewModifier { | |
| let backgroundColor: Color | |
| func body(content: Content) -> some View { | |
| content | |
| .foregroundColor(.white) | |
| .frame(height: 55) | |
| .frame(maxWidth: .infinity) | |
| .background(backgroundColor) | |
| .cornerRadius(10) |
NewerOlder