Skip to content

Instantly share code, notes, and snippets.

View Rsych's full-sized avatar
🙈
I may be slow to respond.

J. W. Kim Rsych

🙈
I may be slow to respond.
View GitHub Profile
@Rsych
Rsych / ReviewMe.swift
Created January 29, 2024 14:35
Review Me
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)
Struct Class
Type Value Reference
Inheritance X O
Type Casting X O
Deinitializers X deinit()
Reference Counting X O
import Cocoa
import SwiftUI
class AppDelegate: NSObject, NSApplicationDelegate {
var statusItem: NSStatusItem!
private lazy var contentView: NSView? = {
let view = (statusItem.value(forKey: "window") as? NSWindow)?.contentView
// 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 :)
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
// 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]
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?) {
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)
import SwiftUI
struct PressableButtonStyle: ButtonStyle {
init(scaleAmount: CGFloat) {
self.scaleAmount = scaleAmount
}
let scaleAmount: CGFloat
func makeBody(configuration: Configuration) -> some View {
configuration.label
.opacity(configuration.isPressed ? scaleAmount : 1.0)
@Rsych
Rsych / CustomViewModifier.swift
Created February 3, 2022 15:20
viewmodifier
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)