웡빙
    • 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
    # 일기장 STEP 2 PR ###### tags: `PR` ## 📁 FileTree ``` └── Diary ├── CoreData │ ├── Diary+CoreDataClass │ ├── Diary+CoreDataProperties │ └── CoreDataManager ├── DiaryList │ ├── DiaryListView │ ├── DiaryListViewController │ └── DiaryListCell ├── Diary │ ├── DiaryView │ ├── DiaryViewController │ └── MyActivityItemSource ├── Model │ ├── DiaryModel │ ├── JsonPaser │ ├── NameSpace │ └── PageMode ├── Extensions │ ├── TimeInterval+Extension │ └── Notification.Name+Extension ├── AppDelegate ├── SceneDelegate ├── Info.plist └── Diary.xcdatamodeld ``` ## 💻 구현사항 ### 구동화면 | 새로운 일기생성 | 새로운 일기생성2 | |:---:|:---:| |<img src = "https://i.imgur.com/VfdObZB.gif" width="250" height="500">|<img src = "https://i.imgur.com/ETR7gTZ.gif" width="250" height="500">| | 일기 공유 | 일기 공유2 | |:---:|:---:| |<img src = "https://i.imgur.com/YxX0yRb.gif" width="250" height="500">|<img src = "https://i.imgur.com/Dd2KeW5.gif" width="250" height="500">| | 일기 삭제 | 일기 삭제2 | 일기 삭제3 | |:---:|:---:|:---:| |<img src = "https://i.imgur.com/GRVDElJ.gif" width="200" height="400">|<img src = "https://i.imgur.com/wMj7Jaf.gif" width="200" height="400">|<img src = "https://i.imgur.com/jJRuBMu.gif" width="200" height="400">| ### 공통 **- SwiftLint 적용** O **- 가로/세로 모드 모두 대응가능** O **- UI는 모두 코드를 통해 구현** O ### STEP 2-1 **- 코어데이터 DB 구현** - 싱글톤 패턴을 이용하여 CoreDataManager 를 생성 및 CRUD 기능구현 - Create: 새로운 일기장 생성 - Read: 일기장 데이터 불러오기 - Update: 수정된 일기데이터 저장 - Delete: 일기장 삭제 **- 기타 기능구현** - "+" 버튼 탭시 새로운 일기장을 생성하는 화면 진입 -> 키보드 자동으로 띄워주기 - 일기 셀을 탭시 해당 일기로 들어가서 일기 수정 - 초기폰트를 LargeTitle로 설정 / 줄바꿈 두번 시 폰트를 body 로 변경 - 자동 저장 - 키보드가 내려갈 시 저장 - 백그라운드 진입 시 저장 - 뒤로가기 할 때 저장 ### STEP 2-2 **- 더보기 버튼 구현** - 일기 작성화면 내 더보기 버튼 탭시 ActionSheet 호출 - Share : ActivityController 호출 - Delete : 삭제얼럿을 띄워준 뒤, 삭제버튼 탭시 해당 일기데이터 삭제 **- UISwipeActionsConfiguration 활용** - 리스트 셀의 trailing에서 스와이프 시, [공유, 삭제] 아이콘 표현 - 공유 버튼 탭시 ActivityController 호출 - 삭제 버튼 탭시 해당 데이터 삭제 ## 🛠 Trouble Shooting ### - TextView 에서 행끼리 줄어드는 현상 --해결 attributedString의 사용에서 문제가 발생한 것으로 확인. 제목과 본문을 연결해주기 위해 "\n\n" 문자열 자체를 append 시켜주었더니 오류가 발생했다. 해당 문자열을 append가 아닌 diaryTitle 뒤에 더해주었더니 오류해결 ```swift! let attributedString = NSMutableAttributedString(string: diaryTitle, attributes: [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .title1)]) attributedString.append("\n\n") // 이 부분 때문에 오류가 발생 attributedString.append(NSMutableAttributedString(string: diaryBody, attributes: [NSAttributedString.Key.font: UIFont.preferredFont(forTextStyle: .body)])) return attributedString } ``` ![](https://i.imgur.com/5bxnHpk.png) ### - ActivityViewTitle - ActicityViewController의 Title에 일기의 제목과 본문을 넣으려고 처음엔 아래 처럼 배열을 넣어줬더니 아래의 사진과 같이 윗부분은 Plain Text라고 나오고 저희가 넣어준 제목과 본문은 한줄로 나오는 현상이 발생했습니다. ```swift UIActivityViewController(activityItems: ["title", body], applicationActivities: nil) ``` - 그래서 찾은 방법이 MyActivityItemSource를 통해서 각각의 상황에 맞는 아이템을 지정해 주는 방법이었습니다. 여기서 우리가 원하는 plain Text의 위치에 제목이 들어가기 위해 MyActivityItemSource프로토콜의 메서드 중 subjectForActivityType을 title로 지정하고 여기에 제목을 넣어주는 방법을 통해 지금의 결과를 얻어 낼 수 있었습니다. |오류 상황|현재 상황| |:--:|:--:| |<img src = "https://i.imgur.com/nI4QX5f.png" width="300" height="300">|<img src = "https://i.imgur.com/amp0N1U.png" width="300" height="300">| ## 🤷‍♂️ 질문사항 ### 코어데이터 저장공간 - 기능요구서에서 coreData의 저장곤간을 Apllication Support로 지정하라고 되어 있어서 원래의 Coredata가 어디에 저장되는지 알아보기 위해 아래의 블로그를 참고 하였습니다. - 확인결과 특별한 지정이 없이도 Aplliaction Support폴더에 저장이 되고 있는 것을 확인하였습니다. https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=jdub7138&logNo=220464393861 - 이런식으로 확인하면 되는것인지 아니면 다른 방법으로도 확인을 할 수 있는지 궁금합니다. 그리고 지금 저희가 확인한 것처럼 Apllication Support에 저장이되고 있는것이 맞는지도 궁금합니다. ### 네임스페이스 - 코드상에서 사용되는 문자열과 숫자를 네임스페이스로 분리 해주는 작업을 진행하였습니다. 사용되는 모든 매직리터럴을 분리해주려 했지만, 양이 너무 많아 고민이 되었습니다. 어떤 것을 분리시켜주고 어떤 것을 분리시켜주지 않는지 쿠마의 경우 이런 네임스페이스 분리의 기준이 어떻게 되시는지 궁금합니다 !

    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