Skip to content

Instantly share code, notes, and snippets.

View AppleCEO's full-sized avatar
๐Ÿ’ป

๋„๋ฏธ๋‹‰ AppleCEO

๐Ÿ’ป
View GitHub Profile
@AppleCEO
AppleCEO / Square.swift
Created May 27, 2019 09:20
๋ถ€๋ชจ ํด๋ž˜์Šค๊ฐ€ ์žˆ์„ ๋•Œ ์ด๋‹ˆ์…œ๋ผ์ด์ € ์œ„์ž„
class Shape {
var numberOfSides: Int = 0
var name: String
init(name: String) {
self.name = name
}
}
class Square: Shape {
@AppleCEO
AppleCEO / Square.swift
Created May 27, 2019 09:27
์ง€์ • ์ด๋‹ˆ์…œ๋ผ์ด์ €์˜ ์ƒ์† ์˜ˆ์ œ
class Shape {
var numberOfSides: Int = 0
var name: String
init(name: String) {
self.name = name
}
}
class Square: Shape { }
@AppleCEO
AppleCEO / RecipeIngredient.swift
Created May 27, 2019 09:34
๋ถ€๋ชจ ํด๋ž˜์Šค์˜ ๋ชจ๋“  ์ง€์ • ์ด๋‹ˆ์…œ๋ผ์ด์ €๋ฅผ ์˜ค๋ฒ„๋ผ์ด๋”ฉํ•ด์ค€ ๊ฒฝ์šฐ ๋ถ€๋ชจ์˜ ํŽธ์˜ ์ด๋‹ˆ์…œ๋ผ์ด์ €๋“ค๋„ ์ƒ์†๋˜๋Š” ์˜ˆ์ œ
class Food {
var name: String
init(name: String) {
self.name = name
}
convenience init() {
self.init(name: "[์ด๋ฆ„ ์—†์Œ]")
}
}
@AppleCEO
AppleCEO / Animal.swift
Created May 28, 2019 06:31
ํด๋ž˜์Šค์—์„œ ์‹คํŒจ ๊ฐ€๋Šฅํ•œ ์ด๋‹ˆ์…œ๋ผ์ด์ € ์˜ˆ์ œ
class Animal {
let species: String
init?(species: String) {
if species.isEmpty { return nil }
self.species = species
}
}
var animal = Animal(species: "")
@AppleCEO
AppleCEO / InputView.swift
Created June 7, 2019 08:12
์ธํ’‹์„ ๋‹ด๋‹นํ•˜๋Š” ๋ชจ๋“ˆ
import Foundation
struct InputView {
private func printMenuInputGuidance () {
print("์นด๋“œ ๊ฒŒ์ž„ ์ข…๋ฅ˜๋ฅผ ์„ ํƒํ•˜์„ธ์š”.")
print("1. 7์นด๋“œ")
print("2. 5์นด๋“œ")
print("9. ์ข…๋ฃŒ")
}
@AppleCEO
AppleCEO / Protocol.swift
Created June 7, 2019 10:02
๋น„๊ต ์˜ˆ์ œ 1
protocol Test { }
extension Int: Test { }
extension Array: Test where Element == Test { }
let arr1 = Array<Test>()
let arr2 = Array<Int>()
arr1 is Test
arr2 is Test
@AppleCEO
AppleCEO / Protocol.swift
Created June 7, 2019 10:02
๋น„๊ต ์˜ˆ์ œ 2
protocol Test { }
extension Int: Test { }
extension Array: Test where Element: Test { }
let arr1 = Array<Test>()
let arr2 = Array<Int>()
arr1 is Test
arr2 is Test
@AppleCEO
AppleCEO / gist:0b5df339ed898674f38b836a264c96cb
Created June 8, 2019 16:29 — forked from ihoneymon/how-to-write-by-markdown.md
๋งˆํฌ๋‹ค์šด ์‚ฌ์šฉ๋ฒ•

[๊ณตํ†ต] ๋งˆํฌ๋‹ค์šด markdown ์ž‘์„ฑ๋ฒ•

1. ๋งˆํฌ๋‹ค์šด์— ๊ด€ํ•˜์—ฌ

1.1. ๋งˆํฌ๋‹ค์šด์ด๋ž€?

Markdown์€ ํ…์ŠคํŠธ ๊ธฐ๋ฐ˜์˜ ๋งˆํฌ์—…์–ธ์–ด๋กœ 2004๋…„ ์กด๊ทธ๋ฃจ๋ฒ„์— ์˜ํ•ด ๋งŒ๋“ค์–ด์กŒ์œผ๋ฉฐ ์‰ฝ๊ฒŒ ์“ฐ๊ณ  ์ฝ์„ ์ˆ˜ ์žˆ์œผ๋ฉฐ HTML๋กœ ๋ณ€ํ™˜์ด ๊ฐ€๋Šฅํ•˜๋‹ค. ํŠน์ˆ˜๊ธฐํ˜ธ์™€ ๋ฌธ์ž๋ฅผ ์ด์šฉํ•œ ๋งค์šฐ ๊ฐ„๋‹จํ•œ ๊ตฌ์กฐ์˜ ๋ฌธ๋ฒ•์„ ์‚ฌ์šฉํ•˜์—ฌ ์›น์—์„œ๋„ ๋ณด๋‹ค ๋น ๋ฅด๊ฒŒ ์ปจํ…์ธ ๋ฅผ ์ž‘์„ฑํ•˜๊ณ  ๋ณด๋‹ค ์ง๊ด€์ ์œผ๋กœ ์ธ์‹ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋งˆํฌ๋‹ค์šด์ด ์ตœ๊ทผ ๊ฐ๊ด‘๋ฐ›๊ธฐ ์‹œ์ž‘ํ•œ ์ด์œ ๋Š” ๊นƒํ—™(https://github.com) ๋•๋ถ„์ด๋‹ค. ๊นƒํ—™์˜ ์ €์žฅ์†ŒRepository์— ๊ด€ํ•œ ์ •๋ณด๋ฅผ ๊ธฐ๋กํ•˜๋Š” README.md๋Š” ๊นƒํ—™์„ ์‚ฌ์šฉํ•˜๋Š” ์‚ฌ๋žŒ์ด๋ผ๋ฉด ๋ˆ„๊ตฌ๋‚˜ ๊ฐ€์žฅ ๋จผ์ € ์ ‘ํ•˜๊ฒŒ ๋˜๋Š” ๋งˆํฌ๋‹ค์šด ๋ฌธ์„œ์˜€๋‹ค. ๋งˆํฌ๋‹ค์šด์„ ํ†ตํ•ด์„œ ์„ค์น˜๋ฐฉ๋ฒ•, ์†Œ์Šค์ฝ”๋“œ ์„ค๋ช…, ์ด์Šˆ ๋“ฑ์„ ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ธฐ๋กํ•˜๊ณ  ๊ฐ€๋…์„ฑ์„ ๋†’์ผ ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฐ•์ ์ด ๋ถ€๊ฐ๋˜๋ฉด์„œ ์ ์  ์—ฌ๋Ÿฌ ๊ณณ์œผ๋กœ ํผ์ ธ๊ฐ€๊ฒŒ ๋œ๋‹ค.

1.2. ๋งˆํฌ๋‹ค์šด์˜ ์žฅ-๋‹จ์ 

1.2.1. ์žฅ์ 

@AppleCEO
AppleCEO / fontSize.swift
Created June 13, 2019 08:58
label fontSize change
let fontSize = UIFont.boldSystemFont(ofSize: 60)
attributedString.addAttribute(kCTFontAttributeName as NSAttributedString.Key, value: fontSize, range: NSRange(location: 0, length: 3))
let descriptionFontSize = UIFont.boldSystemFont(ofSize: 40)
descriptionAttributedString.addAttribute(kCTFontAttributeName as NSAttributedString.Key, value: descriptionFontSize, range: NSRange(location: 0, length: 5))
@AppleCEO
AppleCEO / color.swift
Created June 13, 2019 09:01
label foregroundColor change
descriptionAttributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.white, range: NSRange(location: 0, length: 2))
descriptionAttributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor.red, range: NSRange(location: 3, length: 2))