입찰
    • 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
    • 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 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
    # method swizzling이 무엇이고, 어떨 때 사용하는지 설명하시오 > 🔑 키워드: 런타임, 다이나믹 디스패치 - 런타임 시점에 특정 메서드를 다른 메서드로 바꾸어 실행하는 기능을 말합니다. 이는 "런타임 시점에서 호출될 함수를 결정하는" 다이나믹 디스패치 특징 덕분에 가능한 기능입니다. - 앱에 분석기능을 통합할 때 즉, 프레임워크에서 자동으로 실행하는 메서드에 대해서 런타임을 체크할 때 사용합니다. 또는 특정 기능을 클래스 & 서브 클래스 모두 한 번에 적용시키고 싶을 때 method swizzling을 통해 런타임시에 기존 메서드를 다른 메서드로 swizzling합니다. ### [요약] 이럴때 사용합니다. - 이미 정해진 iOS의 특정 메서드가 실행될 때 - 해당 메서드 대신 다른 메서드가 실행되도록 바꿀 때 - 앱에 분석기능을 통합할 때 - 특정 기능을 클래스&서브 클래스 모두 한 번에 적용시키고 싶을 때 --- ## 꼬리질문 ### 예시를 하나 들어주실 수 있나요? - ViewController마다 ViewWillAppear 메서드를 오버라이딩을 한다고 할 때, ViewController가 많아지면 많아질 수록, 똑같은 내용의 코드를 매번 작성해야 할 일이 많아집니다. 이런 경우 UIViewController를 상속받는 서브 클래스를 만들어주고, viewWillAppear를 오버라이딩 한 후, 이후 ViewController에서 이 서브 클래스를 상속받게 하는 방법이 있습니다. 이럴 때 사용하는 것이 Method Swizzling 입니다. ### 구체적인 사용방법에 대해서 설명해주세요. > 🔑 키워드: 타입 메서드, `class_getInstanceMethod`, AppDelegate - 타입 메서드안에 #selector를 통해 기존 메서드와 바꾸어줄 메서드를 설정해줍니다. - class_getInstanceMethod(cls: AnyClass, name: Selctor) 메서드에 호출해서 첫번째 파라미터에 기존 메서드가 위치한 타입, 두번째 파라미터에 기존 메서드를 넣어줍니다. - 앞서 말한 class_getInstanceMethod 호출 과정을 파라미터에 바꾸어줄 메서드를 넣어주어 반복합니다. - AppDelegate에 만들어둔 타입메서드를 호출해줍니다. ### 단점은 없을까요? - 만약 어떠한 뷰에서는 저 기능을 사용하고 싶지않다고 해도 역할을 대체해버렸기에 원하는 동작을 못합니다. 즉 예상치 못한 버그를 발생시킬 가능성이 높아지고, 또한 프레임워크나 라이브러리를 가져와 사용할때 이미 스위즐링 되어있을 수 있는데 이걸 다시 스위즐링을 하면 앱이 멈출 수 있습니다. - 또한, iOS 버전이 올라감에 따라 swizzling한 메서드가 바뀌면 문제가 발생할 수도 있습니다. - 이외에 중간에 메서드가 바뀌는 과정이 들어간 만큼 가독성면에서 문제가 생겨 협업에 어려움이 있을 수도 있다는 점도 있습니다. - 그만큼 method swizzling은 남용하지 않고 꼭 필요할 때만 사용해야한다고 판단할 수 있습니다. #### 출처 [Swift) Method Swizzling을 알아보자](https://babbab2.tistory.com/76) [Method Swizzling](https://green1229.tistory.com/209)

    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