class MyCell: UITableViewCell {
let gradientLayer = CAGradientLayer()
}
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
class Solution: | |
# sliding window(O(n)) | |
def numberOfArithmeticSlices(self, nums: List[int]) -> int: | |
def numberOfArithmeticArr(n: int) -> int: | |
if n < 3: | |
return 0 | |
return ((n - 2) * (n - 1)) // 2 | |
if len(nums) < 3: | |
return 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
func allSubClass<T>(of targetClass: T, bundle: Bundle) -> [T] { | |
var count: UInt32 = 0 | |
guard let allClasses = objc_copyClassList(&count) else { | |
return [] | |
} | |
let targetClasses: [T] = (0..<count).compactMap { index in | |
let someClass: AnyClass = allClasses[Int(index)] | |
guard Bundle(for: someClass) == bundle else { return 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
func allSubClass<T>(of targetClass: T, bundle: Bundle) -> [T] { | |
var count: UInt32 = 0 | |
guard let allClasses = objc_copyClassList(&count) else { | |
return [] | |
} | |
let targetClasses: [T] = (0..<count).compactMap { index in | |
let someClass: AnyClass = allClasses[Int(index)] | |
guard Bundle(for: someClass) == bundle else { return 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
class VC: ViewController { | |
var keyboardVisible = true | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: .UIKeyboardWillShow, object: nil) | |
} | |
deinit { | |
NotificationCenter.default.removeObserver(self) |
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 | |
struct ReadInput { | |
private var currentIndex: Int = 0 | |
private var inputArray: [String] = [] | |
// 데이터를 배열로 변환 | |
public mutating func readLineToArray() -> [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
// p1 | |
import Foundation | |
func problem1(n: Int, arr1: [Int], arr2: [Int]) { | |
let binaryArr1 = generateBinaryArray(arr: arr1, length: n) | |
let binaryArr2 = generateBinaryArray(arr: arr2, length: n) |
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 | |
// Use Basic Encoder & Decoder By Codable | |
struct Book: Codable { | |
var title: String | |
var author: String | |
var price: Int | |
} | |
let book1 = Book(title: "Hello World", author: "hcn1519", price: 10000) |
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 | |
let fileManager = FileManager() | |
let documentsDirectory = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first! | |
let dataPath = documentsDirectory.appendingPathComponent("FileManager Directory") | |
do { | |
try fileManager.createDirectory(atPath: dataPath.path, withIntermediateDirectories: false, attributes: nil) |
NewerOlder