๊ธ€ ์ž‘์„ฑ์ž: ๊ฐœ๋ฐœํ•˜๋Š” ํ›ˆ์ด

NotificationCenter 

์˜ต์ €๋ฒ„ ํŒจํ„ด? ๋ฐœํ–‰-๊ตฌ๋… ํŒจํ„ด?

์ด์ „ ํฌ์ŠคํŠธ์—์„œ ์˜ต์ €๋ฒ„ ํŒจํ„ด๊ณผ ํŽ์„ญํŒจํ„ด์œผ๋กœ ๋ถˆ๋ฆฌ๋Š” ๋ฐœํ–‰-๊ตฌ๋… ํŒจํ„ด์„ ์ •๋ฆฌํ•œ ์ ์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ๋‘ ํŒจํ„ด์— ๋Œ€ํ•œ ์ดํ•ด๊ฐ€ ์žˆ์œผ๋ฉด ํ›จ์”ฌ ๋” ์žฌ๋ฏธ์žˆ์œผ๋‹ˆ ๋‘ ํฌ์ŠคํŠธ๋ฅผ ๋จผ์ € ์ฐธ๊ณ ํ•ด์ฃผ์„ธ์š”! [์˜ต์ €๋ฒ„ํŒจํ„ด][ํŽ์„ญํŒจํ„ด] ์Šค์œ„ํ”„ํŠธ์˜ NotificationCenter๋Š” ๋ฐœํ–‰-๊ตฌ๋… ํŒจํ„ด๊ณผ ์œ ์‚ฌํ•˜๊ฒŒ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค. ๋ฐœํ–‰-๊ตฌ๋… ํŒจํ„ด์—์„œ ์ด๋ฒคํŠธ ๋ธŒ๋กœ์ปค์— ํ•ด๋‹นํ•˜๋Š” ์ค‘๊ฐœ์ž์˜ ์—ญํ• ์„ NotificationCenter ๊ฐ์ฒด๊ฐ€ ํ•˜๊ฒŒ๋˜์ฃ . NotificationCenter๋ผ๋Š” ์ด๋ฆ„์ฒ˜๋Ÿผ ์ž์‹ ์—๊ฒŒ ๋“ฑ๋ก๋œ ์นœ๊ตฌ๋“ค์—๊ฒŒ ์•Œ๋ฆผ์„ ๋ณด๋‚ด์ฃผ๋Š” ๊ฐ์ฒด๊ฐ€ NotificationCenter์ž…๋‹ˆ๋‹ค!

์šฉ์–ด ์ •๋ฆฌ

๋จผ์ € NotificationCenter์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์šฉ์–ด๋ถ€ํ„ฐ ์ •๋ฆฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

NotificationCenter

์•ž์„œ ์„ค๋ช…ํ•œ ๊ฒƒ์ฒ˜๋Ÿผ, NotificationCenter๋Š” ๊ฐ์ฒด๋กœ๋ถ€ํ„ฐ ์–ด๋–ค ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›์•„ ์ž์‹ ์—๊ฒŒ ๋“ฑ๋ก๋œ ๊ฐ์ฒด๋“ค์—๊ฒŒ ์•Œ๋ฆผ์„ ๋ณด๋‚ด์ฃผ๋Š” ๊ฐ์ฒด์ž…๋‹ˆ๋‹ค. NotificationCenter๋Š” ์‹ฑ๊ธ€ํ†ค์œผ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ์–ด ์‚ฌ์šฉ์ž๊ฐ€ ์ธ์Šคํ„ด์Šค๋ฅผ ๋งŒ๋“ค์ง€ ์•Š๊ณ  NotificationCenter๋ฅผ ๋ถ€๋ฅผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋™์‹œ์— ์‹ฑ๊ธ€ํ†ค์ด๊ธฐ ๋•Œ๋ฌธ์— ๋ฐœ์ƒํ•˜๋Š” ๋ฌธ์ œ์ ๋„ ์žˆ๋Š”๋ฐ์š”, A์™€ B๋ผ๋Š” ๊ฐ์ฒด๊ฐ€ ์žˆ์„ ๋•Œ, ์–ด๋–ค ์ด๋ฒคํŠธ๋ฅผ A๋งŒ ๋ฐ›๊ฒŒ ํ•˜๊ณ  ์‹ถ์–ด๋„ A์™€ B๋Š” NotificationCenter์˜ ์‹ฑ๊ธ€ํ†ค ์ธ์Šคํ„ด์Šค๋ฅผ ๊ณต์œ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋‘ ๊ฐ์ฒด๊ฐ€ ๋ชจ๋‘ ์•Œ๋ฆผ์„ ๋ฐ›๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๋ฌผ๋ก  ์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ์Šต๋‹ˆ๋‹ค! ์•„๋ž˜์—์„œ ๋” ์ž์„ธํžˆ ์„ค๋ช…ํ•ด๋ณผ๊ฒŒ์š”~!

Observer

์˜ต์ €๋ฒ„ ํŒจํ„ด์˜ Observer๋ผ๋Š” ์šฉ์–ด๋ฅผ ๊ธฐ์–ตํ•˜์‹œ๋‚˜์š”? NotificationCenter์˜ Observer๋Š” NotificationCenter์— ์ž์‹ ์˜ ์ •๋ณด๋ฅผ ๋“ฑ๋กํ•˜์—ฌ ์•Œ๋ฆผ์„ ๋ฐ›๊ณ ์ž ํ•˜๋Š” ๊ฐ์ฒด๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๋ชจ๋“  ๊ฐ์ฒด๋Š” Observer๊ฐ€ ๋  ์ˆ˜๋„ ์žˆ๊ณ , ์ด๋ฒคํŠธ๋ฅผ ๋ณด๋‚ด๋Š” ๊ฐ์ฒด๊ฐ€ ๋  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

Post

Post๋Š” ๊ฐ์ฒด๊ฐ€ NotificationCenter๋กœ ์ด๋ฒคํŠธ๋ฅผ ๋ณด๋‚ด๋Š” ํ–‰์œ„๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. ๋ฐœํ–‰-๊ตฌ๋… ํŒจํ„ด์—์„œ ๋ฐœํ–‰์— ํ•ด๋‹น๋œ๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋˜๊ฒ ์ฃ ?

Notification

Notification์€ ์ด๋ฒคํŠธ๋ฅผ ๋ฐœํ–‰ํ•˜๋Š” ๊ฐ์ฒด๊ฐ€ NotificationCenter์— ๋ณด๋‚ด๋Š” ์ด๋ฒคํŠธ๋ฅผ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค. 

NotificationName

์œ„์—์„œ NotificationCenter๋Š” ์‹ฑ๊ธ€ํ†ค์ด๋ผ๊ณ  ํ–ˆ์—ˆ์ฃ ? ๊ทธ๋Ÿผ ์ด๋ฒคํŠธ๋ฅผ ์—ฌ๋Ÿฌ ๊ฐœ ๋งŒ๋“ค๊ณ  ์‹ถ์„ ๋•Œ๋Š” ์–ด๋–ป๊ฒŒ ํ• ๊นŒ์š”? ์˜ˆ๋ฅผ ๋“ค์–ด, ์ƒ‰์ƒ์„ ๋ฐ”๊พธ๋Š” ์•Œ๋ฆผ, ์„  ๋‘๊ป˜๋ฅผ ๋ฐ”๊พธ๋Š” ์•Œ๋ฆผ์„ ๋ณด๋‚ด๊ณ ์ž ํ•œ๋‹ค๋ฉด, ์‹ฑ๊ธ€ํ†ค์ธ NotificaionCenter๋Š” ์ž์‹ ์—๊ฒŒ ๋ณด๋‚ด์ง€๋Š” ์ด๋ฒคํŠธ๊ฐ€ ์–ด๋–ค ์ด๋ฒคํŠธ์ธ์ง€ ์•Œ๊ณ  ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์ด๋ฒคํŠธ๋ฅผ ๋ณด๋‚ด๋Š” ๊ฐ์ฒด๋Š” NotificationName์ด๋ผ๋Š” ์‹๋ณ„์ž๋ฅผ NotificationCenter์— ์•Œ๋ ค์ฃผ์–ด์„œ ์ด๋ฅผ ๊ตฌ๋ถ„ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ฉ๋‹ˆ๋‹ค.

์‚ฌ์šฉํ•ด๋ณด๊ธฐ

๊ทธ๋Ÿผ ์ด์ œ ๊ฐ„๋‹จํ•œ ์˜ˆ์ œ๋ฅผ ํ†ตํ•ด์„œ ์ฃผ์š”ํ•œ ๊ธฐ๋Šฅ๋“ค์„ ์‚ฌ์šฉํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค!

import Foundation

class Chatter {
    let name: String
    let isMaster: Bool
    
    init(name: String, isMaster: Bool) {
        self.name = name
        self.isMaster = isMaster
    }
    
    func join(to room: GroupChatRoom) {
    }
    func send(message: String, to room: GroupChatRoom) {
    }
    func sendToMaster(message: String, to room: GroupChatRoom) {
    }
}

class GroupChatRoom {
    let name: String
    init(name: String) {
        self.name = name
    }
    func send(message: String, senderName: String) {
    }
    func sendToMaster(message: String, senderName: String) {
    }
}

๋จผ์ € ์•„์ฃผ ๊ธฐ๋ณธ์ ์ธ ๊ตฌํ˜„์„ ํ•ด๋‘์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฃน์ฑ„ํŒ…๋ฐฉ์„ ํ‘œํ˜„ํ•˜๋Š” GroupChatRoom์€ ์‚ฌ์šฉ์ž๋“ค์ด ๋ณด๋‚ด๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ์ด ๋ฐฉ์— ๊ฐ€์ž…๋œ ๋ชจ๋“  ์‚ฌ์šฉ์ž๋“ค์—๊ฒŒ ์ „๋‹ฌํ•˜๋Š” ์—ญํ• ์„ ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ ์‚ฌ์šฉ์ž๋“ค์€ ์ด๋ฆ„๊ณผ, ๋ฐฉ์žฅ์ธ์ง€ ์—ฌ๋ถ€์— ๋Œ€ํ•œ ์ •๋ณด๋งŒ ๊ฐ€์ง€๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ํŠน์ •ํ•œ ๊ทธ๋ฃน์ฑ„ํŒ…๋ฐฉ์— ๊ฐ€์ž…ํ•˜๊ฑฐ๋‚˜, ํ•ด๋‹น ๋ฐฉ์— ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ผ ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์˜ˆ์ œ์—์„œ์˜ ๋ชฉํ‘œ๋Š” ์‚ฌ์šฉ์ž๋“ค์ด ๋ณด๋‚ด๋Š” ๋ฉ”์‹œ์ง€๋ฅผ GroupChatRoom์„ ํ†ตํ•ด ์ฑ„ํŒ…๋ฐฉ์— ๊ฐ€์ž…๋œ ๋‹ค๋ฅธ ์‚ฌ์šฉ์ž๋“ค์—๊ฒŒ ๋ฟŒ๋ ค์ฃผ๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. 

 

์ œ๊ฐ€ ์›ํ•˜๋Š” ์‹œ๋‚˜๋ฆฌ์˜ค๋Š” ์ด๋ ‡์Šต๋‹ˆ๋‹ค:

 

  1. ๊ทธ๋ฃน ์ฑ„ํŒ…๋ฐฉ์— ๊ฐ€์ž…ํ•˜๋ฉด ์ž๋™์œผ๋กœ Observer๊ฐ€ ๋œ๋‹ค.
  2. ์‚ฌ์šฉ์ž๋“ค์€ "SendMessage"๋ผ๋Š” NotificationName์œผ๋กœ ์ž์‹ ์ด ๋ณด๋‚ด๊ณ ์ž ํ•˜๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ์ด๋ฒคํŠธ๋กœ ๋ฐœํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค. 
  3. ์‚ฌ์šฉ์ž๋“ค์€ "SendMessage"์— ๋Œ€ํ•œ ์•Œ๋ฆผ์„ ๋ฐ›์œผ๋ฉด ์ž์‹ ์˜ ์ด๋ฆ„๊ณผ ๋ฐ›์€ ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
  4. ์‚ฌ์šฉ์ž๋“ค์€ "SendMessageToMaster"๋ผ๋Š” NotificationName์œผ๋กœ ๋ฐฉ์žฅ์—๊ฒŒ๋งŒ ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๋Š” ์ด๋ฒคํŠธ๋ฅผ ๋ฐœํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค.
  5. ๋ฉ”์‹œ์ง€๋“ค์€ ํ•œ ์ฑ„ํŒ…๋ฐฉ ๋‚ด์—์„œ๋งŒ ์œ ํšจํ•˜๊ณ  ๋‹ค๋ฅธ ์ฑ„ํŒ…๋ฐฉ์—๋Š” ์ „์†ก๋˜์ง€ ์•Š๋Š”๋‹ค. 

๊ทธ๋Ÿผ ์œ„ ์‹œ๋‚˜๋ฆฌ์˜ค๋ฅผ ๊ทธ๋Œ€๋กœ ๊ตฌํ˜„ํ•ด๋ณด๋„๋ก ํ•ฉ๋‹ˆ๋‹ค!

1. ๊ทธ๋ฃน์ฑ„ํŒ…๋ฐฉ์— ๊ฐ€์ž…ํ•˜๋ฉด ์ž๋™์œผ๋กœ Observer๊ฐ€ ๋œ๋‹ค.

์‚ฌ์šฉ์ž๋“ค์ด ๊ฐ€์ž…์„ ํ•  ๋•Œ, ์˜ต์ €๋ฒ„๋กœ ๋“ฑ๋ก์„ ํ•ด์ฃผ๋ฉด ๋˜๋Š”๋ฐ์š”, NotificationCenter์—์„œ๋Š” addObserver ๋ฉ”์„œ๋“œ๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

func addObserver(
		_ observer: Any, 
        selector aSelector: Selector, 
        name aName: NSNotification.Name?, 
        object anObject: Any?
        )

์ด๋ ‡๊ฒŒ addObserver์™€ ๋„ค ๊ฐ€์ง€ ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ ํŒŒ๋ผ๋ฏธํ„ฐ๋Š” ๊ณต์‹๋ฌธ์„œ์— ๋‚˜์™€์žˆ๋Š” ๋Œ€๋กœ ์ •๋ฆฌํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค!

observer

์˜ต์ €๋ฒ„๋กœ ๋“ฑ๋กํ•  ๊ฐ์ฒด๋ฅผ ๋„ฃ์–ด์ค๋‹ˆ๋‹ค. ์šฐ๋ฆฌ์˜ ์˜ˆ์‹œ์—์„œ๋Š” ์ฑ„ํŒ…๋ฐฉ์— ์ฐธ์—ฌํ•˜๋Š” ๊ฐ ์ฐธ์—ฌ์ž๋“ค์˜ ์ธ์Šคํ„ด์Šค๋ฅผ ๋„ฃ์–ด์ฃผ๋ฉด ๋˜๊ฒ ๋„ค์š”.

aSelector

aSelector๋Š” ์˜ต์ €๋ฒ„๊ฐ€ Notification์„ ๋ฐ›์•˜์„ ๋•Œ ์ˆ˜ํ–‰ํ•  ์ž‘์—…์ด ๋ฌด์—‡์ธ์ง€ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค. Object-C ํ•จ์ˆ˜๋ฅผ ์ •์˜ํ•˜๊ณ  ํ•จ์ˆ˜์˜ ์ด๋ฆ„์„ selector๋กœ ์ž‘์„ฑํ•ด์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ๋ฐ›์•˜์„ ๋•Œ ์ด๋ฆ„๊ณผ ๋ฐ›์€ ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅ๊ธฐ๋กœ ํ–ˆ์œผ๋‹ˆ ์ด์— ๋Œ€ํ•œ ๋กœ์ง์„ ๊ตฌํ˜„ํ•œ ํ•จ์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ๋ฉด ๋˜๊ฒ ์ฃ ?

aName

name์€ ์ „๋‹ฌ๋ฐ›์€ Notification์˜ ์ด๋ฆ„์„ ์ ์Šต๋‹ˆ๋‹ค. ์ด ์˜ต์ €๋ฒ„๋“ค์ด ์–ด๋–ค ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›์„์ง€ ์—ฌ๊ธฐ์„œ ๊ฒฐ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋งŒ์•ฝ nil์„ ๊ฐ’์œผ๋กœ ๋„ฃ์œผ๋ฉด NotificationName์„ ๊ณ ๋ คํ•˜์ง€ ์•Š๊ณ  ๋ชจ๋“  Notification์„ ๋ฐ›๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๊ฐ€ ๋ณด๋‚ผ ์ด๋ฒคํŠธ๋Š” ๋‘ ์ข…๋ฅ˜์˜€์ฃ ? SendMessage, SendMessageToMaster๋ฅผ ์ด๊ณณ์— ๋“ฑ๋กํ•ด๋ณด๋ฉด ์–ด๋–จ๊นŒ์š”?

anObject

์ด ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ํ†ตํ•ด์„œ Notification์„ ๋ณด๋‚ด๋Š” ๊ฐ์ฒด๋ฅผ ํŠน์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์šฐ๋ฆฌ์˜ ์˜ˆ์‹œ์—์„œ๋Š” ์—ฌ๋Ÿฌ ์ฑ„ํŒ…๋ฐฉ๋ผ๋ฆฌ๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ๊ณต์œ ํ•˜๋ฉด ์•ˆ ๋˜๊ธฐ ๋•Œ๋ฌธ์— ์ž์‹ ์ด ์†ํ•œ ์ฑ„ํŒ…๋ฐฉ์—์„œ ์˜ค๋Š” ๋ฉ”์‹œ์ง€๋งŒ ๋ฐ›๋„๋ก ํ•ด์•ผ๊ฒ ๋„ค์š”. 

 

๊ทธ๋Ÿผ ๊ตฌํ˜„ํ•ด๋ณผ๊นŒ์š”?

func join(to room: GroupChatRoom) {
    NotificationCenter.default.addObserver(
        self,
        selector: #selector(didReceiveMessage(_:)),
        name: Notification.Name("SendMessage"),
        object: room
    )
    if self.isMaster {
        NotificationCenter.default.addObserver(
            self,
            selector: #selector(didReceiveMessageToMaster(_:)),
            name: Notification.Name("SendMessageToMaster"),
            object: room
        )
    }
}

Chatter ํด๋ž˜์Šค์— join ๋ฉ”์„œ๋“œ๋ฅผ ์œ„์™€ ๊ฐ™์ด ๊ตฌํ˜„ํ•˜์˜€์Šต๋‹ˆ๋‹ค. ๊ฐ ์‚ฌ์šฉ์ž๋“ค์€ join ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•ด์„œ ์ž์‹ ์ด ๊ฐ€์ž…ํ•  ์ฑ„ํŒ…๋ฐฉ ๊ฐ์ฒด๋ฅผ ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ€์ž…๋˜๋Š” ์ˆœ๊ฐ„์— ๊ฐ€์ž…ํ•œ ์ฑ„ํŒ…๋ฐฉ์— ๋Œ€ํ•œ Observer๋กœ ์‚ฌ์šฉ์ž๋“ค์„ ๋“ฑ๋กํ•ด์•ผ ํ•˜๋Š”๋ฐ์š”, ์ด๋ฅผ ์œ„ํ•ด์„œ addObserver ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜๊ณ  ์ธ์ž๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค. 

 

  1. observer: self - ์ฑ„ํŒ…๋ฐฉ์— ๊ฐ€์ž…ํ•œ ์‚ฌ์šฉ์ž ์ž๊ธฐ ์ž์‹ ์„ NotificationCenter์— ๋“ฑ๋กํ•ฉ๋‹ˆ๋‹ค.
  2. selector: #selector(didReceiveMessage) - ์ด๋ฒคํŠธ์— ๋Œ€ํ•œ ์•Œ๋ฆผ์„ ๋ฐ›์•˜์„ ๋•Œ ์‹คํ–‰ํ•  ๋ฉ”์„œ๋“œ๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ๋Š” didReceiveMessage๋กœ ์ง€์ •ํ–ˆ์Šต๋‹ˆ๋‹ค. ์ด์ œ ๊ฐ™์€ ํด๋ž˜์Šค ๋‚ด๋ถ€์— ํ•ด๋‹น ํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ•ด์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  3. name: Notification.Name("SendMessage"): Notification์˜ ์ด๋ฆ„์„ SendMessage๋กœ ํ•˜๊ธฐ๋กœ ํ–ˆ์—ˆ์ฃ ? ๊ทธ๋Œ€๋กœ ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.
  4. object: room - ์ฑ„ํŒ…๋ฐฉ์— ๊ฐ€์ž…๋œ ์‚ฌ์šฉ์ž๋“ค ์—ฌ๋Ÿฌ ์ฑ„ํŒ…๋ฐฉ ์ค‘์—์„œ ์ž์‹ ์ด ๊ฐ€์ž…ํ•œ ์ฑ„ํŒ…๋ฐฉ์—์„œ ์˜ค๋Š” ๋ฉ”์‹œ์ง€๋งŒ ๋ฐ›์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋ฐœ์‹ ์ž ๊ฐ์ฒด๋ฅผ ๊ฐ€์ž…ํ•œ ์ฑ„ํŒ…๋ฐฉ์œผ๋กœ ์ง€์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์œ„์™€ ๊ฐ™์€ ๋ฐฉ๋ฒ•์œผ๋กœ ๋งŒ์•ฝ ์‚ฌ์šฉ์ž๊ฐ€ ๋ฐฉ์žฅ์ผ ๊ฒฝ์šฐ์—๋Š” ๋ฐฉ์žฅ์—๊ฒŒ ๋ณด๋‚ด๋Š” ๋ฉ”์‹œ์ง€์— ๋Œ€ํ•œ Observer๋ฅผ ์ถ”๊ฐ€์ ์œผ๋กœ ๋“ฑ๋กํ•˜๊ฒŒ ํ–ˆ์Šต๋‹ˆ๋‹ค. selector์— ๋„ฃ์–ด์ฃผ์—ˆ๋˜ ๋ฉ”์„œ๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

    @objc func didReceiveMessage(_ notification: Notification) {
    	print("receive")
    }
    @objc func didReceiveMessageToMaster(_ notification: Notification) {
    	print("receive from member to master")
    }

์ง€๊ธˆ์€ ์ผ๋‹จ ์ด๋ ‡๊ฒŒ ๋‹จ์ˆœํ•˜๊ฒŒ ๊ตฌํ˜„ํ•ด๋‘๊ฒ ์Šต๋‹ˆ๋‹ค. NotificationCenter์— ์ง€์ •ํ•˜๋Š” ๋ฉ”์„œ๋“œ๋Š” ํ•ญ์ƒ ์ ์–ด๋„ ํ•œ ๊ฐœ์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ๊ฐ€์ง‘๋‹ˆ๋‹ค. Notification์œผ๋กœ ์ „๋‹ฌ๋˜๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ๊ฐ์ฒด์ž…๋‹ˆ๋‹ค. 

 

2. ์‚ฌ์šฉ์ž๋“ค์€ "SendMessage"๋ผ๋Š” NotificationName์œผ๋กœ ์ž์‹ ์ด ๋ณด๋‚ด๊ณ ์ž ํ•˜๋Š” ๋ฉ”์‹œ์ง€๋ฅผ ์ด๋ฒคํŠธ๋กœ ๋ฐœํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค. 

์ด์ œ ๋ฉ”์‹œ์ง€๋ฅผ ์ด๋ฒคํŠธ๋กœ ๋ฐœํ–‰ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์•„๊นŒ ๋งŒ๋“ค์—ˆ๋˜ Chatter ๊ฐ์ฒด์™€ GroupChatRoom ๊ฐ์ฒด์˜ send ๋ฉ”์„œ๋“œ๋ฅผ ๊ตฌํ˜„ํ•˜๋ฉด ๋˜๊ฒ ์ฃ ?

func send(message: String, to room: GroupChatRoom) {
        room.send(message: message, senderName: self.name)
}
func sendToMaster(message: String, to room: GroupChatRoom) {
        room.sendToMaster(message: message, senderName: self.name)
}

Chatter์— ์žˆ๋Š” ๋ฉ”์„œ๋“œ๋Š” ๋‹จ์ˆœํ•˜๊ฒŒ ์ž์‹ ์˜ ์ด๋ฆ„์„ ํฌํ•จํ•ด์„œ GroupChatRoom์— ์ „๋‹ฌํ•ด์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค. 

 

๊ทธ๋ฆฌ๊ณ  ์ด๋ ‡๊ฒŒ ํ˜ธ์ถœ๋˜๋Š” GroupChatRoom ๊ฐ์ฒด์˜ send ๋ฉ”์„œ๋“œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ตฌํ˜„ํ•ด๋ด…์‹œ๋‹ค.

func send(message: String, senderName: String) {
        NotificationCenter.default.post(
            name: Notification.Name("SendMessage"), 
            object: self, 
            userInfo: ["message":message, "room":self.name, "senderName":senderName]
        )
}
func sendToMaster(message: String, senderName: String) {
        NotificationCenter.default.post(
            name: Notification.Name("SendMessageToMaster"), 
            object: self, 
            userInfo: ["message":message, "room":self.name, "senderName":senderName]
        )
}

GroupChatRoom์€ ์ž์‹ ์ด ์ง์ ‘ ๋ฉ”์‹œ์ง€๋ฅผ ์ „๋‹ฌํ•˜์ง€ ์•Š๊ณ , NotificationCenter๋กœ ์ž์‹ ์„ ๋ฐœ์‹ ์ž๋กœ ํ•˜์—ฌ ์ด๋ฒคํŠธ๋ฅผ ๋ณด๋ƒ…๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด์„œ NotificationCenter์˜ post ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

func post(
    name aName: NSNotification.Name, 
    object anObject: Any?, 
    userInfo aUserInfo: [AnyHashable : Any]? = nil
)

post ๋ฉ”์„œ๋“œ์˜ ์ •์˜๋Š” ์œ„์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์•ž์—์„œ ์ •์˜ํ–ˆ๋˜ addObserver ๋ฉ”์„œ๋“œ์™€ ๋Œ€์‘๋˜๋Š” ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ€ ๋ณด์ด์ฃ ?

 

name ํŒŒ๋ผ๋ฏธํ„ฐ์—๋Š” ๋ณด๋‚ด๊ณ ์ž ํ•˜๋Š” Notification์˜ ์ด๋ฆ„์„ ์ ์–ด์ค๋‹ˆ๋‹ค. object์—๋Š” ์ด Notification์„ ๋ณด๋‚ด๋Š” ๋ฐœ์‹ ์ž ๊ฐ์ฒด๋ฅผ ๋‹ด๊ณ , userInfo์—๋Š” ์ถ”๊ฐ€์ ์ธ ๋ฐ์ดํ„ฐ๋“ค์„ ๋‹ด์•„ ๋ณด๋ƒ…๋‹ˆ๋‹ค.

๐Ÿ’ก object ํŒŒ๋ผ๋ฏธํ„ฐ์—๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ๋‹ด๋Š” ๊ฒŒ ์•„๋‹™๋‹ˆ๋‹ค! object์— ๋“ค์–ด๊ฐ€๋Š” ๊ฐ์ฒด์˜ ์ •๋ณด๋กœ addObserver๋ฅผ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ ์ •์˜ํ•œ ๋ฐœ์‹ ์ž๋ฅผ ์‹๋ณ„ํ•˜๊ธฐ ๋•Œ๋ฌธ์— object์—๋Š” ๋ฐœ์‹ ์ž ๊ฐ์ฒด๋ฅผ ๋‹ด๊ณ  ํ•จ๊ป˜ ์ „๋‹ฌํ•˜๊ณ ์ž ํ•˜๋Š” ๋ฐ์ดํ„ฐ๋“ค์€ userInfo์— ๋‹ด๋Š” ๊ฒƒ์ด ์›์น™์ž…๋‹ˆ๋‹ค.

userInfo์— ๋‹ด์„ ๋ฐ์ดํ„ฐ๋Š” ๋”•์…”๋„ˆ๋ฆฌ๋กœ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ์˜ ์˜ˆ์ œ์—์„œ๋Š” ๋ฐœ์‹ ์ž ์ •๋ณด์— ๊ทธ๋ฃน์ฑ„ํŒ…๋ฐฉ ๊ฐ์ฒด๋ฅผ ๋‹ด๊ณ , ๋ฉ”์‹œ์ง€, ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋‚ด๋Š” ์‚ฌ๋žŒ์˜ ์ด๋ฆ„, ์ฑ„ํŒ…๋ฐฉ์˜ ์ด๋ฆ„์„ ๋‹ด์•„์„œ Notification์„ ๋ณด๋ƒ…๋‹ˆ๋‹ค. 

 

3. ์‚ฌ์šฉ์ž๋“ค์€ "SendMessage"์— ๋Œ€ํ•œ ์•Œ๋ฆผ์„ ๋ฐ›์œผ๋ฉด ์ž์‹ ์˜ ์ด๋ฆ„๊ณผ ๋ฐ›์€ ๋ฉ”์‹œ์ง€๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.

์•„๊นŒ ์ž ์‹œ ๋ฏธ๋ฃจ์–ด๋‘์—ˆ๋˜ Chatter ๊ฐ์ฒด์˜ ๋ฉ”์„œ๋“œ๋ฅผ ๊ตฌํ˜„ํ•  ์ฐจ๋ก€์ž…๋‹ˆ๋‹ค. ์ด๋ฒคํŠธ๋ฅผ ์„ฑ๊ณต์ ์œผ๋กœ ๋ฐ›์œผ๋ฉด addObserver ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•  ๋•Œ selector ์ธ์ž์— ์ถ”๊ฐ€ํ•ด์ฃผ์—ˆ๋˜ ๋ฉ”์„œ๋“œ๊ฐ€ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ธ์ž๋กœ Notification ๊ฐ์ฒด๊ฐ€ ์ „๋‹ฌ๋˜์ฃ . Notification ๊ฐ์ฒด ์•ˆ์—๋Š” Notification์„ ๋ณด๋‚ผ ๋•Œ ๋‹ด์•˜๋˜ ์ •๋ณด๊ฐ€ ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” Notification์„ ๋ณด๋‚ผ ๋•Œ, userInfo์— ์ •๋ณด๋“ค์„ ๋‹ด์•˜๊ธฐ ๋•Œ๋ฌธ์— ์ด๋ฅผ ์‚ฌ์šฉํ•˜๋„๋ก ๋ฉ”์„œ๋“œ๋ฅผ ๊ตฌ์„ฑํ•ด์ฃผ๊ฒ ์Šต๋‹ˆ๋‹ค,

 

    @objc func didReceiveMessage(_ notification: Notification) {
        guard let roomName = notification.userInfo?["room"] as? String,
              let message = notification.userInfo?["message"] as? String,
              let sender = notification.userInfo?["senderName"] as? String else { return }
        print("\(roomName)-\(sender)๋กœ๋ถ€ํ„ฐ์˜ ๋ฉ”์‹œ์ง€: \(message) | \(self.name) ์ˆ˜์‹ ์™„๋ฃŒ")
    }
    @objc func didReceiveMessageToMaster(_ notification: Notification) {
        guard let roomName = notification.userInfo?["room"] as? String,
              let message = notification.userInfo?["message"] as? String,
              let sender = notification.userInfo?["senderName"] as? String else { return }
        print("\(roomName)-\(sender)๋กœ๋ถ€ํ„ฐ์˜ ๋น„๋ฐ€๋ฉ”์‹œ์ง€: \(message) | \(self.name) ์ˆ˜์‹ ์™„๋ฃŒ")
    }

 

๋ฉ”์„œ๋“œ๊ฐ€ ํ˜ธ์ถœ๋˜๋ฉด ์ „๋‹ฌ๋œ Notification ๊ฐ์ฒด์—์„œ userInfo๋ฅผ ์ฐพ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—๋Š” ๋”•์…”๋„ˆ๋ฆฌ๋กœ ์ „๋‹ฌํ•œ ๋ฐ์ดํ„ฐ๊ฐ€ ๋‹ด๊ฒจ ์žˆ๊ฒ ์ฃ ? ๊ทธ๋ž˜์„œ Notification์„ ๋ณด๋‚ผ ๋•Œ ์‚ฌ์šฉํ–ˆ๋˜ ํ‚ค ๊ฐ’๋“ค์„ ๊ทธ๋ž˜๋„ ์‚ฌ์šฉํ•ด์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์–ด์™€ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค. String์œผ๋กœ ๋‹ค์šด ์บ์ŠคํŒ…์„ ์‹œ๋„ํ•˜๋Š” ๋ถ€๋ถ„์ด ์žˆ๋Š”๋ฐ์š”, ์ด์œ ๋Š” post ๋ฉ”์„œ๋“œ์˜ ์›ํ˜•์„ ๋‹ค์‹œ ๋ณด๋ฉด ์•Œ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

userInfo aUserInfo: [AnyHashable : Any]? = nil)

userInfo๋Š” ๋”•์…”๋„ˆ๋ฆฌ์˜ ๊ฐ’์œผ๋กœ Anyํƒ€์ž…์„ ๊ฐ€์ง‘๋‹ˆ๋‹ค. ํƒ€์ž…์ด ํŠน์ •๋˜์ง€ ์•Š์•˜๊ธฐ ๋•Œ๋ฌธ์— Notification์„ ๋ฐ›์€ ๋ฉ”์„œ๋“œ๋Š” ์ „๋‹ฌ๋œ ๋ฐ์ดํ„ฐ์˜ ํƒ€์ž…์„ ์•Œ ์ˆ˜๊ฐ€ ์—†์œผ๋‹ˆ ์›ํ•˜๋Š” ํƒ€์ž…์œผ๋กœ ์บ์ŠคํŒ…์„ ํ•ด์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

 

์—ฌ๊ธฐ๊นŒ์ง€ ํ–ˆ๋‹ค๋ฉด ์ผ๋‹จ ์™„์„ฑ์ž…๋‹ˆ๋‹ค! ํ•œ๋ฒˆ ์‹คํ–‰ํ•ด๋ณผ๊นŒ์š”?

let park = Chatter(name: "๋ฐ•์ค‘์‚ฌ", isMaster: true)
let han = Chatter(name: "ํ•œํ˜ธ์—ด", isMaster: false)
let ahn = Chatter(name: "์•ˆ์ค€ํ˜ธ", isMaster: false)
let dpRoom = GroupChatRoom(name: "DP")

park.join(to: dpRoom)
han.join(to: dpRoom)
ahn.join(to: dpRoom)

park.send(message: "์•ผ", to: dpRoom)
han.sendToMaster(message: "๋ฐ•์ค‘์‚ฌ๋‹˜?", to: dpRoom)

// DP-๋ฐ•์ค‘์‚ฌ๋กœ๋ถ€ํ„ฐ์˜ ๋ฉ”์‹œ์ง€: ์•ผ | ๋ฐ•์ค‘์‚ฌ ์ˆ˜์‹ ์™„๋ฃŒ
// DP-๋ฐ•์ค‘์‚ฌ๋กœ๋ถ€ํ„ฐ์˜ ๋ฉ”์‹œ์ง€: ์•ผ | ํ•œํ˜ธ์—ด ์ˆ˜์‹ ์™„๋ฃŒ
// DP-๋ฐ•์ค‘์‚ฌ๋กœ๋ถ€ํ„ฐ์˜ ๋ฉ”์‹œ์ง€: ์•ผ | ์•ˆ์ค€ํ˜ธ ์ˆ˜์‹ ์™„๋ฃŒ
// DP-ํ•œํ˜ธ์—ด๋กœ๋ถ€ํ„ฐ์˜ ๋น„๋ฐ€๋ฉ”์‹œ์ง€: ๋ฐ•์ค‘์‚ฌ๋‹˜? | ๋ฐ•์ค‘์‚ฌ ์ˆ˜์‹ ์™„๋ฃŒ

์ž˜ ๋™์ž‘ํ•˜๋„ค์š”! 

 

๊ทธ๋Ÿผ ๋ช‡ ๊ฐ€์ง€ ์˜ˆ์™ธ์ƒํ™ฉ๋„ ํ…Œ์ŠคํŠธํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๊ฐ€ ์ •ํ–ˆ๋˜ ์‹œ๋‚˜๋ฆฌ์˜ค์—์„œ ์ž์‹ ์ด ๊ฐ€์ž… ๊ทธ๋ฃน์ฑ„ํŒ…๋ฐฉ์—์„œ ์ „๋‹ฌ๋˜๋Š” ๋ฉ”์‹œ์ง€๋งŒ ๋ฐ›๋Š”๋‹ค๋Š” ์กฐ๊ฑด์ด ์žˆ์—ˆ๋Š”๋ฐ์š”, ๊ทธ๋ฃน์ฑ„ํŒ…๋ฐฉ์„ ํ•˜๋‚˜ ๋” ๋งŒ๋“ค์–ด์„œ ํ…Œ์ŠคํŠธํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

let park = Chatter(name: "๋ฐ•์ค‘์‚ฌ", isMaster: true)
let han = Chatter(name: "ํ•œํ˜ธ์—ด", isMaster: false)
let ahn = Chatter(name: "์•ˆ์ค€ํ˜ธ", isMaster: false)
let dpRoom = GroupChatRoom(name: "DP")

park.join(to: dpRoom)
han.join(to: dpRoom)
ahn.join(to: dpRoom)

let dpRoomWithoutPark = GroupChatRoom(name: "๊ฐ„๋ถ€์—†๋Š” DP ๋ฐฉ")
han.join(to: dpRoomWithoutPark)
ahn.join(to: dpRoomWithoutPark)

park.send(message: "์•ผ", to: dpRoom)
han.sendToMaster(message: "๋ฐ•์ค‘์‚ฌ๋‹˜?", to: dpRoom)

ahn.send(message: "ํ•œํ˜ธ์—ด ์ƒ๋ฑ€๋‹˜?", to: dpRoomWithoutPark)
han.send(message: "์ค€ํ˜ธ์•ผ~~~", to: dpRoomWithoutPark)
han.sendToMaster(message: "๋ฐ•๋ฒ”๊ตฌ ์ค‘์‚ฌ๋‹˜ ๊ฐ™์ด ์ง•๊ณ„ ๋ฐ›์์‹œ๋‹ค~~~!!!!", to: dpRoomWithoutPark)

๊ฐ„๋ถ€ ์—†๋Š” ์ฑ„ํŒ…๋ฐฉ ํ•˜๋‚˜๋ฅผ ๋งŒ๋“ค๊ณ , ๋ฉ”์‹œ์ง€๊ฐ€ ์ž˜ ๋„์ฐฉํ•˜๋Š”์ง€, ๊ทธ๋ฆฌ๊ณ  ๋ฐฉ์žฅ์ด ์—†์„ ๋•Œ ๋ฉ”์‹œ์ง€๊ฐ€ ๋ˆ„๊ตฌ์—๊ฒŒ ์ „๋‹ฌ๋˜๋Š”์ง€ ํ™•์ธํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. 

// DP-๋ฐ•์ค‘์‚ฌ๋กœ๋ถ€ํ„ฐ์˜ ๋ฉ”์‹œ์ง€: ์•ผ | ๋ฐ•์ค‘์‚ฌ ์ˆ˜์‹ ์™„๋ฃŒ
// DP-๋ฐ•์ค‘์‚ฌ๋กœ๋ถ€ํ„ฐ์˜ ๋ฉ”์‹œ์ง€: ์•ผ | ํ•œํ˜ธ์—ด ์ˆ˜์‹ ์™„๋ฃŒ
// DP-๋ฐ•์ค‘์‚ฌ๋กœ๋ถ€ํ„ฐ์˜ ๋ฉ”์‹œ์ง€: ์•ผ | ์•ˆ์ค€ํ˜ธ ์ˆ˜์‹ ์™„๋ฃŒ
// DP-ํ•œํ˜ธ์—ด๋กœ๋ถ€ํ„ฐ์˜ ๋น„๋ฐ€๋ฉ”์‹œ์ง€: ๋ฐ•์ค‘์‚ฌ๋‹˜? | ๋ฐ•์ค‘์‚ฌ ์ˆ˜์‹ ์™„๋ฃŒ
// ๊ฐ„๋ถ€์—†๋Š” DP ๋ฐฉ-์•ˆ์ค€ํ˜ธ๋กœ๋ถ€ํ„ฐ์˜ ๋ฉ”์‹œ์ง€: ํ•œํ˜ธ์—ด ์ƒ๋ฑ€๋‹˜? | ํ•œํ˜ธ์—ด ์ˆ˜์‹ ์™„๋ฃŒ
// ๊ฐ„๋ถ€์—†๋Š” DP ๋ฐฉ-์•ˆ์ค€ํ˜ธ๋กœ๋ถ€ํ„ฐ์˜ ๋ฉ”์‹œ์ง€: ํ•œํ˜ธ์—ด ์ƒ๋ฑ€๋‹˜? | ์•ˆ์ค€ํ˜ธ ์ˆ˜์‹ ์™„๋ฃŒ
// ๊ฐ„๋ถ€์—†๋Š” DP ๋ฐฉ-ํ•œํ˜ธ์—ด๋กœ๋ถ€ํ„ฐ์˜ ๋ฉ”์‹œ์ง€: ์ค€ํ˜ธ์•ผ~~~ | ํ•œํ˜ธ์—ด ์ˆ˜์‹ ์™„๋ฃŒ
// ๊ฐ„๋ถ€์—†๋Š” DP ๋ฐฉ-ํ•œํ˜ธ์—ด๋กœ๋ถ€ํ„ฐ์˜ ๋ฉ”์‹œ์ง€: ์ค€ํ˜ธ์•ผ~~~ | ์•ˆ์ค€ํ˜ธ ์ˆ˜์‹ ์™„๋ฃŒ

์›ํ•˜๋Š” ์‹œ๋‚˜๋ฆฌ์˜ค๋Œ€๋กœ ์ž˜ ๋™์ž‘ํ•˜๋„ค์š”~! ์ด๋ ‡๊ฒŒ NotificationCenter๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐ์ฒด ๊ฐ„์˜ ํ†ต์‹ ์„ ๋” ์‰ฝ๊ฒŒ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค! ๋ฐœํ–‰-๊ตฌ๋… ํŒจํ„ด์˜ ์žฅ์ ์ฒ˜๋Ÿผ, ์ฑ„ํŒ…๋ฐฉ์€ ๋ˆ„๊ฐ€ ์ž์‹ ์—๊ฒŒ ๊ฐ€์ž…๋˜์–ด์žˆ๋Š”์ง€ ์ •๋ณด๋ฅผ ์ €์žฅํ•  ํ•„์š”๊ฐ€ ์—†๊ณ , ๋ฉค๋ฒ„๋“ค๋„ ์–ด๋–ค ๋ฉค๋ฒ„๋“ค์ด ์žˆ๋Š”์ง€ ๋ชปํ•˜๋Š” ์ƒํ™ฉ์—์„œ๋„ ๋ฉ”์‹œ์ง€๋ฅผ ์„ฑ๊ณต์ ์œผ๋กœ ์ „๋‹ฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์‹œ์Šคํ…œ ๋‚ด๋ถ€์ ์œผ๋กœ ๋™์ž‘ํ•˜๋‹ค ๋ณด๋‹ˆ ๋””๋ฒ„๊น…์ด ์–ด๋ ต๋‹ค๋Š” ๋‹จ์ ์ด ์žˆ์ง€๋งŒ ์œ ์šฉํ•˜๊ฒŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ์ˆ ์ธ ๊ฒƒ ๊ฐ™๋„ค์š”. 

 

๊ธด ๊ธ€ ์ฝ์–ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค~! ์ž˜๋ชป๋œ ๋‚ด์šฉ์ด ์žˆ๋‹ค๋ฉด ์•Œ๋ ค์ฃผ์„ธ์š”!

 

์˜ˆ์ œ ์ฝ”๋“œ ์ „์ฒด