Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

๐ŸคŸ๐Ÿป 3์ฃผ์ฐจ ์„ธ๋ฏธ๋‚˜ #10

Merged
merged 10 commits into from
Aug 1, 2023

Conversation

ena-isme
Copy link
Contributor

@ena-isme ena-isme commented Aug 1, 2023

3์ฃผ์ฐจ

3์ฃผ์ฐจ ์„ธ๋ฏธ๋‚˜์—์„œ๋Š” ๊ฐ„๋‹จํ•œ ๋‹น๊ทผ๋งˆ์ผ“ ํด๋ก  ์ฝ”๋”ฉ์„ ํ†ตํ•˜์—ฌ TableView ์— ๋Œ€ํ•œ ๊ฐœ๋…์„ ๊ณต๋ถ€ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

์ฃผ์š”์ฝ”๋“œ


CarrotTableViewCell ์—์„œ ์ดˆ๊ธฐํ™”ํ•  ๋•Œ, init ๋งŒ ์ž‘์„ฑํ•˜๋ฉด required' initializer 'init(coder:)' must be provided by subclass of 'UITableViewCell' ์™€ ๊ฐ™์€ ์—๋Ÿฌ ๋ฐœ์ƒํ•˜์—ฌ ์•„๋ž˜ required init ์ž๋™ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.


init(corder: _) ๋Š” storyboard ์ƒ์—์„œ ์ดˆ๊ธฐํ™”ํ•ด์ฃผ๋Š” ํ•จ์ˆ˜์ด๊ณ  init(frame: _) ๋Š” ์ฝ”๋“œ ์ƒ์—์„œ ์ดˆ๊ธฐํ™”ํ•ด์ฃผ๋Š” ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค. ์ด๋•Œ ์šฐ๋ฆฌ๊ฐ€ ๊ตฌํ˜„ํ•˜๊ณ  ์žˆ๋Š” UIView ์™€ UIViewController๋Š” NSCoding ๋ฅผ ์ฑ„ํƒํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. NSCoding ๋Š” init(corder: _) ์ฑ„ํƒ๋ฅผ ์ฑ„ํƒํ•˜๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ์ฝ”๋“œ๋กœ ์ž‘์„ฑ๊ณ ์žˆ์ง€๋งŒ init(frame: _)์ด ์•„๋‹Œ init(corder: _) ๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. required ๋ฅผ ์ด์šฉํ•˜์—ฌ init(corder: _)๋ฅผ ์š”์ฒญํ•ด์ค„ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด์ฃ  !


override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        setStyle()
        setLayout()
}

required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
}

๊ฐ€๊ฒฉ Label ๋ฅผ ๊ตฌํ˜„ํ•  ๋•Œ, ๋’ค์—์„œ ์„ธ ๋ฒˆ์งธ ์ˆซ์ž ๋‹ค์Œ์— ',' ๋ฅผ ์จ ๊ตฌ๋ถ„ํ•ด์ฃผ๊ธฐ ์œ„ํ•ด ์•„๋ž˜์™€ ๊ฐ™์€ ์ฝ”๋“œ๋ฅผ ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค. index ๋ฅผ ๊ณ„์‚ฐํ•ด์ฃผ๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.


var price = String(carrot.price)
        price.insert(",", at: price.index(price.endIndex, offsetBy: -3))
        priceLabel.text = price + "์›"

์‹ค์Šต๊ฒฐ๊ณผ


Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-08-01.at.15.34.41.mp4

#6

@ena-isme ena-isme self-assigned this Aug 1, 2023
@ena-isme ena-isme merged commit 370e578 into main Aug 1, 2023
@ena-isme ena-isme changed the title 3์ฃผ์ฐจ ์„ธ๋ฏธ๋‚˜ 3๏ธโƒฃ 3์ฃผ์ฐจ ์„ธ๋ฏธ๋‚˜ Aug 2, 2023
@ena-isme ena-isme changed the title 3๏ธโƒฃ 3์ฃผ์ฐจ ์„ธ๋ฏธ๋‚˜ ๐ŸคŸ๐Ÿป 3์ฃผ์ฐจ ์„ธ๋ฏธ๋‚˜ Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant