Short
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 만국박람회 ## 👀 고민한 점 - 처음에는 customCell을 활용하여 image, title, subtitle을 구현하였습니다. 하지만, 블로그에서 본 글에선 아래 사진처럼 UITableViewCell은 기본속성으로 titleLable, detailTextLabel, imageView를 갖고 있다는 말을 듣고 구현하려하였습니다. 하지만, 현재는 공식문서에서 사용하지 않는다고 나와있었고, 결국에는 customCell을 활용하였습니다. ![](https://i.imgur.com/1Ceox0B.png) - 파리박람회에서 다른 박람회로 포스터가 바뀐다면 네임스페이스를 사용하면 더 간편하게 바꿀 수 있다고 생각합니다. 하지만, 우리는 Assets의 파일 이름까지 네임스페이스를 할 필요가 있을까? 파일이 바뀌지 않는 영역이기때문에 변경도 될 여지가 없으므로 파일명을 직접 사용하는 것으로 결정하였습니다. 저희의 선택이 옳은 방법일까요? ```swift func configureViewFromImageAsset() { posterImageView.image = UIImage(named: "poster") leftFlagImageView.image = UIImage(named: "flag") rightFlagImageView.image = UIImage(named: "flag") } ``` - 현재는 디코딩 방식을 해당 json데이터가 쓰일 곳에서 디코딩해주는 함수를 만들어서 해당 뷰컨트롤러 내부에서 디코딩을 해줬습니다. 하지만, 이 방법 외에도 별도의 모델에서 디코딩을 미리 해주고, 그 모델의 디코딩해주는 메서드를 뷰컨트롤러에서 불러와서 쓸 수도 있을 것 같다는 생각을 했습니다. (이 부분을 쓰다보니... MVC패턴에 의하면 무조건 Model에 디코딩을 처리해주는 메서드가 들어가야한다는 생각이 드네요.. 이 부분에 대해서 답변해주신다면 리팩토링 해보겠습니다!!) ```swift func jsonDecoding() { let jsonDecoder: JSONDecoder = JSONDecoder() guard let dataAsset: NSDataAsset = NSDataAsset(name: "items") else { return } do { items = try jsonDecoder.decode([Items].self, from: dataAsset.data) } catch { print(error.localizedDescription) } } ``` ## 궁금한점 - json데이터를 특정 단어에서 줄바꿈해주기위해, json데이터를 받아오고 난 후, "(" 를 기준으로 데이터를 개행 해주는 함수를 구현하였습니다. 하지만, 메서드를 구현하면서 이게 과연 좋은 방법일까? 다른방법이 있을 것 같은데? 분명 현업에서도 많이 고민할 것 같은 부분이라고 생각이들어 토니는 어떻게 처리하시는지 팁이 있는지 궁금하여 질문드립니다. ![](https://i.imgur.com/Fzve5UU.png) ```swift func splitParagraph(of title: String) -> String { var separatedTexts = title.components(separatedBy: "(") separatedTexts.insert("\n(", at: 1) return separatedTexts.joined() } ``` - 뷰컨 데이터를 다음뷰컨으로 전달하기위해서 저희는 Segue를 이용해서 데이터를 전달하였습니다. 하지만, 이 방법은 다음뷰컨의 인스턴스에 직접 접근하여 값을 지정해주므로 뷰컨끼리 강하게 결합된다는 문제가 있다고 알고 있습니다. - 그럼에도 segue를 통해서 데이터를 전달한 이유 ? 부스트코스 날씨앱에서 segue를 통해서 주고받았기에 이 방법을 채택해서 사용하였습니다. - 만약 저희가 segue로 데이터를 전달하는 방법을 알지 못했더라면, didselectedlow로 셀이 선택 되었을 때 해당하는 indexPath를 delegate를 이용해서 detailEntryViewController에 전달하여, 디코딩 된 item의 indexpath를 통해 해당하는 선택된 indexpath의 item에 접근했을것 같습니다. - 그렇다면, segue를 통해서 데이터를 주고받는 것은 결합을 높이기에 쓰면 안되는 금지된 코드인건가요?? 저희는 이 부분을 고민하였습니다. 어떨 때, delegate를 이용하고, 어떨 때 segue를 활용하고, 어떨때 notificationCenter를 활용하고.. 이런게 감이 잘안옵니다 토니는 어떻게 이것들을 구별하여 사용하시는지요? ```swift override func prepare(for segue: UIStoryboardSegue, sender: Any?) { guard let detailEntryViewController: DetailEntryViewController = segue.destination as? DetailEntryViewController else { return } guard let indexPath = tableView.indexPathForSelectedRow else { return } detailEntryViewController.jsonName = items[indexPath.row].name detailEntryViewController.jsonDesc = items[indexPath.row].desc detailEntryViewController.jsonImageName = items[indexPath.row].imageName } } ``` - 코드를 작성하다보면 위의 코드에서 처럼 "items[indexPath.row]" 와 같이 반복이 발생하게 되는데, 이럴때 인스턴스로 빼기도 하고 저희가 사용한 코드처럼 하나하나 작성해주기도 하는데 items[indexPath.row]도 상수로 저장해서 사용하는게 좋은 방법인지 궁금합니다! ```swift func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { guard let cell = tableView.dequeueReusableCell(withIdentifier: customCell, for: indexPath) as? EntryTableViewCell else { return UITableViewCell() } cell.entryImageView.image = UIImage(named: items[indexPath.row].imageName) cell.entryLabel.text = items[indexPath.row].name cell.entrySubLabel.text = items[indexPath.row].shortDesc return cell } } ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully