사과
  • 애플 개발자 문서 한글 번역
  • App Frameworks
    • Foundation
      • 숫자, 데이터와 기본값
      • 문자열과 텍스트
      • 컬렉션
      • 날짜와 시간
      • 데이터 포맷
      • 작업 관리
        • Operation
        • OperationQueue
        • Timer
      • 리소스
        • Bundle
      • 파일 시스템
        • FileManager
      • Notification
        • NSKeyValueObserving
      • URL 로딩 시스템
        • 웹사이트 데이터를 메모리에 저장하기
        • URLSession
          • URLSessionConfiguration
            • urlCache
            • requestCachePolicy
          • configuration
        • URLSessionTask
        • URLRequest
        • URLResponse
        • HTTPURLResponse
        • 캐시 데이터에 접근하기
        • CachedURLResponse
        • URLCache
      • Object Runtime
        • NSValue
    • UIKit
      • UIKit으로 앱 개발
      • 앱과 환경
        • 앱 라이프 사이클 관리하기
        • 앱 실행에 대응하기
        • UIApplication
      • 문서, 데이터와 클립보드
      • Mac Catalyst
        • iPad 앱을 Mac 버전으로 만들기
        • 아이패드 앱의 맥 최적화
      • 뷰와 컨트롤
        • UIView
        • Table Views
          • UITableView
          • UITableViewCell
          • UIRefreshControl
        • UIScrollView
      • View Controllers
        • UIViewController
        • UITableViewController
        • UISearchController
      • 애니메이션과 햅틱
        • 프로퍼티 기반 애니메이션
          • UIViewPropertyAnimator
        • View controller 전환
      • 터치, 누르기, 제스처
        • UIResponder
        • UIKit 제스처 처리
        • 다중 제스처 인식기 조정
        • UILongPressGestureRecognizer
        • UIPanGestureRecognizer
          • maximumNumberOfTouches
          • minimunNumberOfTouches
          • translation(in:)
          • setTranslation(_:in:)
          • velocity(in:)
        • UIGestureRecognizer
    • Swift
      • 스위프트 표준 라이브러리
        • 메모리 직접 관리
          • 포인터 파라미터를 사용하는 함수 호출
          • UnsafePointer
          • UnsafeMutableRawBufferPointer
    • SwiftUI
      • 뷰와 컨트롤
        • View
        • Text
        • TextField
      • 뷰 레이아웃과 표현
      • 그리기와 애니메이션
      • 프레임워크 통합
      • 상태와 데이터 흐름
  • Graphics and Games
    • Core Animation
      • CALayer
      • CAAction
      • CAShapeLayer
      • CADisplayLink
    • Core Graphics
      • CGFloat
      • CGPath
  • App Services
    • Combine
    • WebKit
      • WKWebView
  • Media
    • AVFoundation
      • 시스템 오디오 상호작용
        • AVAudioSession
          • AVAudioSession.Category
            • ambient
            • multiRoute
            • playAndRecord
            • playback
            • record
            • soloAmbient
          • AVAudioSession.Mode
      • AVFoundation 자료형
  • Documentation Archive
    • 번들 프로그래밍 가이드
      • 번들에 대해
      • 번들 구조
    • Key-Value Observing 프로그래밍 가이드
    • Threading 프로그래밍 가이드
      • About Threaded Programming
      • Thread Management
  • ETC
    • Not Found
Powered by GitBook
On this page
  • 주제
  • 첫 스텝
  • 타입이 결정된 포인터
  • 원시 포인터
  • 메모리 접근
  • 메모리 레이아웃
  • 참조 카운팅
  • 같이 보기
  • 프로그래밍 작업
  1. App Frameworks
  2. Swift
  3. 스위프트 표준 라이브러리

메모리 직접 관리

Previous스위프트 표준 라이브러리Next포인터 파라미터를 사용하는 함수 호출

Last updated 6 years ago

원문 출처

주제

첫 스텝

  • 포인터를 파라미터로 받는 함수를 호출할때 암시적인 포인터 캐스팅이나 브릿징을 사용하세요.

타입이 결정된 포인터

타입이 결정된 포인터와 버퍼를 사용해서 메모리의 특정 타입 인스턴스에 접근하세요

  • struct 특정 타입의 데이터에 접근하는 포인터

  • struct UnsafeMutablePointer 특정 타입의 데이터에 접근하고 조작하는 포인터

  • struct UnsafeBufferPointer A nonowning collection interface to a buffer of elements stored contiguously in memory.

  • struct UnsafeMutableBufferPointer A nonowning collection interface to a buffer of mutable elements stored contiguously in memory.

원시 포인터

raw 바이트를 저장하고 로딩하기 위해서 원시 포인터와 버퍼를 사용하세요.

  • struct UnsafeRawPointer 타입이 정해지지 않은 데이터에 접근하는 원시 포인터

  • struct UnsafeMutableRawPointer 타입이 정해지지 않은 데이터에 접근하고 조작하는 원시 포인터

  • struct UnsafeRawBufferPointer A nonowning collection interface to the bytes in a region of memory.

  • A mutable nonowning collection interface to the bytes in a region of memory.

메모리 접근

  • func withUnsafePointer<T, Result>(to: T, (UnsafePointer<T>) -> Result) -> Result 주어진 인자에 대한 포인터를 사용하여 클로저를 실행합니다. Beta

  • func withUnsafePointer(to: inout T, (UnsafePointer) -> Result) -> Result

    주어진 인자에 대한 포인터를 사용하여 클로저를 실행합니다.

  • func withUnsafeMutablePointer(to: inout T, (UnsafeMutablePointer) -> Result) -> Result

    주어진 인자의 Mutable 포인터를 사용하여 클로저를 실행합니다.

  • func withUnsafeBytes(of: T, (UnsafeRawBufferPointer) -> Result) -> Result

    주어진 인자의 raw byte를 커버하는 Buffer 포인터를 사용하여 클로저를 실행합니다. Beta

  • func withUnsafeBytes(of: inout T, (UnsafeRawBufferPointer) -> Result) -> Result

    주어진 인자의 raw byte를 커버하는 Buffer 포인터를 사용하여 클로저를 실행합니다.

  • func withUnsafeMutableBytes(of: inout T, (UnsafeMutableRawBufferPointer) -> Result) -> Result

    주어진 인자의 raw byte를 커버하는 Mutable buffer 포인터를 사용하여 클로저를 실행합니다.

  • func swap(inout T, inout T)

    두 인자의 값을 바꿉니다.

메모리 레이아웃

  • enum MemoryLayout The memory layout of a type, describing its size, stride, and alignment.

참조 카운팅

  • struct Unmanaged 관리되지 않는 객체 참조를 전파하기 위한 타입

  • func withExtendedLifetime(T, (T) -> Result) -> Result

    클로저가 반환되기 전에 주어진 인스턴스가 destroy 되지 않도록 보장하면서 클로저를 평가합니다.

  • func withExtendedLifetime(T, () -> Result) -> Result 클로저가 반환되기 전에 주어진 인스턴스가 destroy 되지 않도록 보장하면서 클로저를 평가합니다.

같이 보기

프로그래밍 작업

  • 입출력 값을 콘솔에 출력하고, 텍스트 스트림에 값을 쓰거나 읽고, 커맨드 라인 인자를 사용하세요.

  • 디버깅과 반영 런타임 점검을 통해 코드를 강화하고 값의 런타임 표현을 검토합니다.

  • Key-Path 표현법 Key-Path를 사용해서 프로퍼티에 동적으로 접근하세요.

  • Type Casting and Existential Types 타입간에 캐스팅을 하거나 모든 타입의 값을 나타냅니다.

  • C 상호운용성 import된 C 타입이나 C 가변함수를 사용하세요.

  • 연산자 선언 접두어, 접미어 및 중위어 연산자로 작업하세요.

https://developer.apple.com/documentation/swift/swift_standard_library/manual_memory_management
포인터 파라미터를 사용하는 함수 호출
UnsafePointer
struct UnsafeMutableRawBufferPointer