๊ณต๋ถ€ ์—ฐ์Šต์žฅ :-)

TIL_20180813 ~ 20180818

|

2018.08.13

  • segue๋กœ nextVC๋„์šฐ๊ธฐ์—์„œ nextVC์˜ didSet์—์„œ ์—๋Ÿฌ๊ฐ€ ๋‚˜์„œ ์ •๋ฆฌ
    • ์•„๋ž˜์ฝ”๋“œ์—์„œ ๋ณด๋ฉด SearchViewController์˜ prepare()๋ฉ”์†Œ๋“œ์—์„œ ์Šคํ† ๋ฆฌ๋ณด๋“œ segue์— ๋”ฐ๋ผ์„œ ๋™์ž‘
    • segue๊ฐ€ ์‹คํ–‰๋˜๋ฉด์„œ nextVC์˜ awakeFromNib() ์‹คํ–‰.
    • ์ด๋•Œ nextVC์˜ self๋Š” ์ธ์Šคํ„ด์Šคํ™”๋œ ์ƒํƒœ
    • ์ƒ์œ„๋ชจ๋“ˆ์—์„œ nextVC.branchData์˜ ๋ฐ์ดํ„ฐ ๊ฐ’์„ ๋„˜๊ฒจ์ฃผ๋ฉด์„œ didSet์‹คํ–‰์ด๋˜๋Š”๋ฐ
    • ์ด๋•Œ๊นŒ์ง€๋„ IBOutlet์˜ ํ”„๋กœํผํ‹ฐ๋Š” nil์ƒํƒœ
    • nextVC๊ฐ€ ์ธ์Šคํ„ด์Šคํ™”๋œ ์ƒํƒœ์—ฌ๋„ ๋ทฐ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ์Šคํ† ๋ฆฌ๋ณด๋“œ๋กœ ์—ฐ๊ฒฐ๋œ IBOutlet๋“ค์€ ์ฐธ์กฐ๊ด€๊ณ„๊ฐ€ ๋ถˆ๋ช…ํ™•ํ•œ ์‹œ์ ์ด ์žˆ๋‹ค. ์ด๋•Œ๊ฐ€ ๋ฐ”๋กœ ๊ทธ ์‹œ์ ์ธ๋“ฏํ•˜๋‹ค.
    • viewDidLoad()๊ฐ€ ์‹คํ–‰๋˜๋Š” ์‹œ์ ์—๋Š” nil์ด์—ˆ๋˜ IBOutletํ”„๋กœํผํ‹ฐ๋“ค์ด ๋กœ๋“œ๊ฐ€ ์™„๋ฃŒ๋œ ์‹œ์ 
    • IBOutlet์„ ์„ธํŒ…ํ•˜๋Š” ๋™์ž‘์€ viewDidLoad์—์„œ ํ•˜๋ฉด ๋™์ž‘ํ•œ๋‹ค.

// SearchViewController.swift
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    guard segue.identifier == "showDetail" else { return }
    guard let nextVC = segue.destination as? DetailViewController else { return }
    if let indexPath = tableView.indexPathForSelectedRow {
        if isFiltering() {
            nextVC.branchData = filtered!.branches[indexPath.row]
        } else {
            nextVC.branchData = list!.branches[indexPath.row]
        }
    }
}
}

// DetailViewController.swift
    var branchData: Branch? {
        didSet {
            print("didSet")
        }
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        print(#function)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        setNavigationItem()
        setTitle()
        setAddress()
        setHolidays()
        setPhoneNumber()
    }

2018.08.14

  • https://developers.naver.com/docs/map/ios/

  • ์™ธ๋ถ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์˜ ๋™์ž‘์„ xcode9์˜ main thread checker๊ฐ€ ์ฒดํฌํ•˜๋ฉด์„œ ๋‚˜ํƒ€๋‚˜๋Š” ์—๋Ÿฌ
  • ๋™์ž‘์€ ํ•˜์ง€๋งŒ ๋ฉ”์ธ์Šค๋ ˆ๋“œ์ฒด์ปค์—์„œ UI๋ฅผ ๋‹ด๋‹นํ•˜๋Š” ๋ถ€๋ถ„์€ ๋ฉ”์ธ ์Šค๋ ˆ๋“œ์—์„œ ๋™์ž‘ํ•˜๋„๋ก ๊ตฌํ˜„ํ•˜๋ผ๊ณ  ์—๋Ÿฌ๋ฅผ ๋‚ด๊ฒŒ๋œ๋‹ค. (๋™์ž‘์€ ์ •์ƒ์ ์œผ๋กœ ํ•จ)
  • ์ฐธ๊ณ 
  • ์™ธ๋ถ€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์—์„œ๋Š” ๋™์ž‘ํ•˜์ง€๋งŒ xcode9๊ธฐ์ค€์œผ๋กœ๋Š” ์ฒดํฌํ•ด์•ผํ•˜๋Š” exception์ด๋ผ ์ฒดํ‚น์€ ๋˜์ง€๋งŒ, ์™ธ๋ถ€๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์ด๊ธฐ๋•Œ๋ฌธ์— ์–ด๋””์„œ ์—๋Ÿฌ๊ฐ€ ๋‚˜๋Š”์ง€ ์ฝ”๋“œ๋ผ์ธ์—์„œ ์ฐพ์ง€ ๋ชปํ•œ๋‹ค.
  • ์ด๋ฐฉ๋ฒ•์œผ๋กœ ์ฐพ์„ ์ˆ˜ ๋Š” ์žˆ์ง€๋งŒ ์ฐพ์•„๋„ ์–ด์…ˆ๋ธ”๋ฆฌ์ฝ”๋“œ์ชฝ๊นŒ์ง€ ๋‚ด๋ ค๊ฐ€์„œ ๋ธŒ๋ ˆ์ดํฌํฌ์ธํŠธ๊ฐ€ ๊ฑธ๋ ค์„œ ์–ด๋”˜์ง€ ์•Œ ์ˆ˜ ์—†์Œโ€ฆ
  • ๋Ÿฐํƒ€์ž„์‹œ ์™ธ๋ถ€ api์˜ ์Šค๋ ˆ๋“œ ์ฒดํ‚น์„ ํ•˜์ง€ ์•Š๋„๋ก ์„ค์ •ํ•˜๋ฉด ์—๋Ÿฌ๊ฐ€ ํ‘œ์‹œ๋˜์ง€ ์•Š๊ณ  ์ญ‰ ์‹คํ–‰
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication setNetworkActivityIndicatorVisible:]

2018.08.15

  • ๋ทฐ ์˜คํ† ๋ ˆ์ด์•„์›ƒ ์žก๊ธฐ
  • ์ฆ๊ฒจ์ฐพ๊ธฐ ๋ชจ๋ธ ๊ตฌํ˜„
  • JSONํŒŒ์ผ์ด ๋ณ€๊ฒฝ๋˜์–ด๋„ ๊ทธ๋Œ€๋กœ ์ฆ๊ฒจ์ฐพ๊ธฐ๊ฐ€ ์œ ์ง€๋˜๊ณ  ์—…๋ฐ์ดํŠธ๋˜๋Š”์ง€ ํ™•์ธ

2018.08.16

  • AppDelegate์˜ ์ฝœ๋ฐฑํ•จ์ˆ˜์—์„œ ์ฆ๊ฒจ์ฐพ๊ธฐ ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅ / ๊ฐ€์ ธ์˜ฌ๋•Œ์˜ ์˜๋ฌธ์ 
      func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
          // loadedData๊ฐ€ ์—†๋Š”๊ฒฝ์šฐ favoriteList๋ฅผ ์ €์žฅํ•ด์ฃผ์ง€ ์•Š๊ณ  ๊ทธ๋ƒฅ ๋„˜์–ด๊ฐ€๋ฉด ํ•˜์œ„ ๋ชจ๋“ˆ๋“ค์—์„œ ์ ‘๊ทผํ•˜๋Š” FavoriteList.shared()๋กœ ๋ฐ›๋Š” ์ธ์Šคํ„ด์Šค๋Š” ๋ชจ๋‘ ๊ทธ๋ƒฅ Set<Int>()๋กœ init์ด ๋˜๋‹ˆ๊นŒ ์ƒ๊ด€์—†์Œ
          guard let loadedData = DataStorage<FavoriteList>.load() else { return true }
          FavoriteList.loadSavedData(loadedData) // Favorite๋ฆฌ์ŠคํŠธ๋ฅผ ์ €์žฅํ–ˆ๋˜ ์ธ์Šคํ„ด์Šค๋กœ ๋Œ€์ฒดํ•ด์คŒ
          return true
      }
    
// ์ฒซ ์‹œ์ž‘
application(_:didFinishLaunchingWithOptions:)
applicationDidBecomeActive
// ํ™ˆ๋ฒ„ํŠผ
applicationWillResignActive
applicationDidEnterBackground
// ์‹คํ–‰(๋ฐฑ๊ทธ๋ผ์šด๋“œ์˜€๋‹ค๊ฐ€ ๊ทธ๋Œ€๋กœ ๋‹ค์‹œ๋œฐ๋•Œ)
applicationWillEnterForeground
applicationDidBecomeActive

ํ™ˆ๋ฒ„ํŠผ ๋‘๋ฒˆ ๋ˆŒ๋Ÿฌ์„œ ์œ„๋กœ ์Šค์™€์ดํ”„ํ•˜์—ฌ ๋Œ๋•Œ ํ˜ธ์ถœ์ˆœ์„œ ํ…Œ์ŠคํŠธ

applicationWillResignActive
applicationDidEnterBackground
applicationWillTerminate

ํ…Œ์ŠคํŠธ์‹œ, ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์ƒ๋Œ€๋กœ ๊ฐˆ๋•Œ ํ•ญ์ƒ ํ˜ธ์ถœ๋˜๋Š” ํ•จ์ˆ˜

applicationWillResignActive
applicationDidEnterBackground // ์˜ค๋žซ๋™์•ˆ active์ƒํƒœ๊ฐ€์•„๋‹๋•Œ
  • ์˜ˆ๋น„ / ์ง„์งœ state๋กœ ๋“ค์–ด๊ฐ€๋Š”๊ฑฐ ๊ผญ ๋‘๊ฐœ์”ฉ ํ˜ธ์ถœ๋˜๋Š”๋ฐ ์–ด๋–ป๊ฒŒ ๊ตฌ๋ถ„ํ•˜๊ณ  ํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ•ด์•ผํ• ๊นŒ?
  • ๋ชจ๋‘ ๊ตฌํ˜„ํ•˜๋Š”๊ฒŒ ์ œ์ผ ์ข‹์ง€๋งŒ, ๋˜‘๊ฐ™์€ ๋™์ž‘์„ ๋ฐ˜๋ณตํ•˜๊ฒŒ ํ•˜๊ธฐ ๋ณด๋‹ค๋Š” ํ•ด๋‹น ์ฝœ๋ฐฑ๋“ค์ด ๋ถˆ๋ฆฌ๋Š” ์‹œ๊ฐ„์ฐจ๋™์•ˆ ๋‚ด๊ฐ€ ์ €์žฅํ•  ์ฆ๊ฒจ์ฐพ๊ธฐ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ณ€๊ฒฝ์ด ๋๋Š”์ง€ flag๋ฅผ ๋‘๊ณ  flag์— ๋”ฐ๋ผ์„œ ๋™์ž‘ํ•˜๊ฒŒ ํ•˜๋Š”๊ฒŒ ์ข€ ๋” ๋‚˜์€ ๋ฐฉ๋ฒ•
  • ์•ฑ๋ธ๋ฆฌ๊ฒŒ์ดํŠธ ์ฝœ๋ฐฑํ•จ์ˆ˜ ์ค‘ resignActive๋‚˜ applicationWillTerminate๊ฐ™์€ ํ•จ์ˆ˜์—์„œ ๋น„๋™๊ธฐ์ž‘์—…์„ ํ•˜๋ฉด ํ•ด๋‹น ์ž‘์—…์ด ๋๋‚ ๋–„๊นŒ์ง€๋Š” ์œ ์ง€๋œ๋‹ค๊ณ  ํ•œ๋‹ค. ๋ณดํ†ต์€ 1๋ถ„๋‚ด์™ธ๋กœ ์•Œ๋ ค์ ธ์žˆ์ง€๋งŒ ์‹œ๊ฐ„์ด ๋” ํ•„์š”ํ•˜๋‹ค๋ฉด await์ฒ˜๋ฆฌ๋ฅผ ํ•ด์•ผ ํ•  ๊ฒƒ

2018.08.17

  • ํ…Œ์ด๋ธ”๋ทฐ ์…€์— ์žˆ๋˜ ๋ณ„ ์•„์ด์ฝ˜์„ ๋ฒ„ํŠผ์œผ๋กœ ๋ฐ”๊พธ๊ณ  state๋ณ€๊ฒฝ๋ ๋•Œ๋งˆ๋‹ค๋กœ ํšŒ์ƒ‰๋ณ„ - ๋…ธ๋ž€์ƒ‰ ๋ณ„๋กœ ๋ฐ”๊พธ๋‹ˆ๊นŒ async๋กœ ์ž‘์—…ํ•  ํ•„์š”๊ฐ€ ์—†์–ด์ง
  • ํ…Œ์ด๋ธ”๋ทฐ ์…€์˜ ๋ฐ์ดํ„ฐ๋ฅผ detailํ™”๋ฉด์—์„œ ๋ฐ”๊พธ๊ณ  ํ…Œ์ด๋ธ”๋ทฐ๋กœ ํ™”๋ฉด์ด ๋„˜์–ด๊ฐ€๋„ ํ•ด๋‹น ์…€์€ ์—…๋ฐ์ดํŠธ๋˜์ง€ ์•Š๊ณ  ํ•ด๋‹น ์…€์ด ํ™”๋ฉด์—์„œ ์‚ฌ๋ผ์กŒ๋‹ค๊ฐ€ ๋‚˜ํƒ€๋‚˜๊ฑฐ๋‚˜ search๋™์ž‘์„ ์‹คํ–‰ํ•ด์„œ ํ…Œ์ด๋ธ”๋ทฐ๊ฐ€ reload๋ ๋•Œ๋งŒ ์…€์ด ์—…๋ฐ์ดํŠธ๋จ
    • ์…€์—์„œ reuse๋ ๋•Œ ๋ฒ„ํŠผ ์ƒํƒœ๋ฅผ updateํ•  ์ˆ˜ ์—†์„๊นŒ ๊ณ ๋ฏผํ–ˆ๋Š”๋ฐ,
    • ์ด๋Ÿฐ ๊ฒฝ์šฐ๋Š” ํ…Œ์ด๋ธ”๋ทฐ์ปจํŠธ๋กค๋Ÿฌ์—์„œ reload๋ฅผ ๋ฐ˜๋“œ์‹œ ํ•ด์ค˜์•ผํ•จ!
  • xib๋กœ ์‚ฌ์ด๋“œ๋ฐ” ์—ฐ๊ฒฐํ•จ!!!!!!!!!!!!
    • ์ฝœ๋ ‰์…˜๋ทฐ๋ฅผ ์‚ฌ์šฉํ•˜๋ ค๊ณ ํ–ˆ๋‹ค๊ฐ€ ๊ทธ๋Œ€๋กœ reuseํ•˜๋ฉด ์•ˆ๋ ๊ฑฐ๊ฐ™์•„์„œ.
    • ๊ทธ๋ฆฌ๊ณ  ์Šฌ๋ผ์ด๋“œ ๋ฉ”๋‰ด์— ๋“ค์–ด๊ฐ€๋Š” ๋ฉ”๋‰ด ์ˆ˜๊ฐ€ ๊ทธ๋ฆฌ ๋งŽ์ง€ ์•Š์•„์„œ
    • ๋ฒ„ํŠผ๊ณผ ์Šคํƒ๋ทฐ๋กœ ๊ตฌํ˜„ํ•˜๋ฉด ์˜คํžˆ๋ ค๋” ๋‚ด๊ฐ€ ์›ํ•˜๋Š” ์ฝ”๋“œ์™€ ๋ทฐ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ์„๊ฑฐ๊ฐ™์•„์„œ ๊ตฌํ˜„ํ–ˆ๊ณ , ์ผ๋ฐ˜์ ์ธ ๋ทฐ ์ปจํŠธ๋กค๋Ÿฌ ์œ„์— ๋„์šฐ๋Š” ๋ทฐ๊ฐ€ ์•„๋‹ˆ๋ผ ์‚ฌ์ด์ฆˆ๊ฐ€ ๋‹ค๋ฅด๊ธฐ๋•Œ๋ฌธ์— xib๋กœ ํ–ˆ๋‹ค.
  • ์ปค์Šคํ…€ ๋ธ๋ฆฌ๊ฒŒ์ดํŠธ ๋งŒ๋“ฆ: MainViewController
  • ์Šฌ๋ผ์ด๋“œ ๋ฉ”๋‰ด๋ฅผ ๋‹ซ๋Š” ๋™์ž‘์„ ํ•˜๋Š” ๋ฉ”์†Œ๋“œ๋Š” ์–ด๋””์„œ ๊ตฌํ˜„ํ•ด์•ผํ• ๊นŒ?
    • (์Šฌ๋ผ์ด๋“œ ๋ฉ”๋‰ด๋ฅผ ๋‹ซ๋Š” ๋™์ž‘์„ ์œ„ํ•œ ์˜ต์ €๋ฒ„๋Š” ์–ด๋”” ๊ตฌํ˜„๋˜์–ด์•ผํ• ๊นŒ)
    • SlideMenu์—์„œ ๋‹ซ๊ธฐ ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด noti POST
    • SlideLauncher์—์„œ ๋ฐ›์•„์„œ dismiss๋ฅผ ๋ฐ”๋กœ ํ•ด๋ฒ„๋ ค์•ผํ•˜๋‚˜
    • delegate์ธ ๋ทฐ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ๋ฐ›์•„์„œ dismiss๋ฅผ ํ•ด์ค˜์•ผํ•˜๋‚˜..?

2018.08.18

  • ์ด๋ฏธ์ง€์™€ ํ…์ŠคํŠธ ํ•จ๊ป˜์žˆ๋Š” ๋ฒ„ํŠผ ๋งŒ๋“ค๊ธฐ
  • ์‚ฌ์ด๋“œ๋ฐ”๋ž‘ ๊ฒน์น˜๋Š” statusBar ํ™”๋ฉด์ฒ˜๋ฆฌ
  • ๊ฒฐ๊ตญ ๋„ค๋น„๊ฒŒ์ด์…˜์— embedํ•˜๊ธฐ๋กœโ€ฆ.

Comments