← XPC

XPC Nesneleri

XPC Dokümantasyonu

İlkel tipler, koleksiyonlar ve daha fazlasını temsil eden nesnelere veri kapsülleme.

API Koleksiyonu | XPC


Nesne Tipleri

XPC nesneleri, süreçler arası mesajlaşmada veri taşımak için kullanılan tip-güvenli kaplar sağlar.

Temel Tipler

// Tüm XPC nesnelerini tanımlayan üst tip (sözlükler, diziler, stringler, sayılar vb.)
typealias xpc_object_t

// XPC nesne tiplerini tanımlayan tip
typealias xpc_type_t

// XPC nesnesi arayüzü
protocol OS_xpc_object

Kimlik Sorgulama

// Bir nesnenin tipini döndürür
func xpc_get_type(_ object: xpc_object_t) -> xpc_type_t

// Bir XPC nesne tipini açıklayan string döndürür
func xpc_type_get_name(_ type: xpc_type_t) -> UnsafePointer<CChar>

// Nesne için hash değeri hesaplar
func xpc_hash(_ object: xpc_object_t) -> Int

Karşılaştırma ve Kopyalama

// İki nesneyi eşitlik açısından karşılaştırır
func xpc_equal(_ object1: xpc_object_t, _ object2: xpc_object_t) -> Bool

// Nesnenin bir kopyasını oluşturur
func xpc_copy(_ object: xpc_object_t) -> xpc_object_t?

// Nesneyi açıklayan hata ayıklama dizesi kopyalar
func xpc_copy_description(_ object: xpc_object_t) -> UnsafeMutablePointer<CChar>

Nesne Yaşam Döngüsü

func xpc_retain(_ object: xpc_object_t) -> xpc_object_t   // Referans sayısını artır
func xpc_release(_ object: xpc_object_t)                   // Referans sayısını azalt

Tip Sabitleri

Her XPC nesne tipi için karşılık gelen bir XPC_TYPE_* sabiti mevcuttur:

| Sabit | Nesne Tipi | | --- | --- | | XPC_TYPE_BOOL | Boolean değer | | XPC_TYPE_INT64 | İşaretli 64-bit tam sayı | | XPC_TYPE_UINT64 | İşaretsiz 64-bit tam sayı | | XPC_TYPE_DOUBLE | IEEE çift hassasiyetli kayan nokta | | XPC_TYPE_STRING | Null-sonlandırılmış C dizesi | | XPC_TYPE_DATA | Rastgele bayt tamponu | | XPC_TYPE_DATE | Tarih aralığı | | XPC_TYPE_UUID | Evrensel benzersiz tanımlayıcı | | XPC_TYPE_FD | POSIX dosya tanıtıcı | | XPC_TYPE_SHMEM | Paylaşılan bellek bölgesi | | XPC_TYPE_ENDPOINT | Serileştirilmiş bağlantı | | XPC_TYPE_ARRAY | XPC nesneleri dizisi | | XPC_TYPE_DICTIONARY | C dizelerine göre anahtarlanmış XPC nesneleri sözlüğü | | XPC_TYPE_NULL | Null nesne | | XPC_TYPE_CONNECTION | Adlandırılmış servise bağlantı | | XPC_TYPE_ACTIVITY | XPC etkinlik nesnesi | | XPC_TYPE_ERROR | Hata nesnesi | | XPC_TYPE_RICH_ERROR | Zengin hata nesnesi |


Koleksiyonlar

XPCDictionary (Swift)

Yapı | XPC

*iOS 17.0+, macOS 14.0+*

İstemci ile dinleyici arasındaki mesajların kabı olarak kullanılan anahtar-değer çiftleri tipi.

struct XPCDictionary

Sözlük Nesneleri (C)

// Oluşturma
func xpc_dictionary_create(_ keys: ..., _ values: ..., _ count: Int) -> xpc_object_t
func xpc_dictionary_create_empty() -> xpc_object_t
func xpc_dictionary_create_reply(_ original: xpc_object_t) -> xpc_object_t?

// Genel erişim
func xpc_dictionary_set_value(_ dict: xpc_object_t, _ key: ..., _ value: xpc_object_t?)
func xpc_dictionary_get_value(_ dict: xpc_object_t, _ key: ...) -> xpc_object_t?
func xpc_dictionary_get_count(_ dict: xpc_object_t) -> Int
func xpc_dictionary_apply(_ dict: xpc_object_t, _ applier: (...) -> Bool) -> Bool

// Bağlantı nesneleri
func xpc_dictionary_create_connection(_ dict: xpc_object_t, _ key: ...) -> xpc_connection_t?
func xpc_dictionary_get_remote_connection(_ dict: xpc_object_t) -> xpc_connection_t?
func xpc_dictionary_set_connection(_ dict: ..., _ key: ..., _ conn: xpc_connection_t)

// Mach port'ları
func xpc_dictionary_copy_mach_send(_ dict: xpc_object_t, _ key: ...) -> mach_port_t
func xpc_dictionary_set_mach_send(_ dict: xpc_object_t, _ key: ..., _ port: mach_port_t)

Tip-spesifik erişimciler (getter/setter):

Her ilkel tip için xpc_dictionary_get_* ve xpc_dictionary_set_* varyantları mevcuttur: bool, int64, uint64, double, string, data, date, uuid, fd, array, dictionary.

XPCArray (Swift)

Yapı | XPC

*iOS 17.0+, macOS 14.0+*

XPC nesnelerinin sıralı, rastgele erişimli koleksiyonu.

struct XPCArray

Dizi Nesneleri (C)

// Oluşturma
func xpc_array_create(_ objects: ..., _ count: Int) -> xpc_object_t
func xpc_array_create_empty() -> xpc_object_t

// Genel erişim
func xpc_array_set_value(_ array: xpc_object_t, _ index: Int, _ value: xpc_object_t)
func xpc_array_get_value(_ array: xpc_object_t, _ index: Int) -> xpc_object_t
func xpc_array_append_value(_ array: xpc_object_t, _ value: xpc_object_t)
func xpc_array_get_count(_ array: xpc_object_t) -> Int
func xpc_array_apply(_ array: xpc_object_t, _ applier: (Int, xpc_object_t) -> Bool) -> Bool

Tip-spesifik erişimciler:

xpc_array_get_* ve xpc_array_set_* varyantları: bool, int64, uint64, double, string, data, date, uuid, fd, connection, array, dictionary.

XPC_ARRAY_APPEND sabiti, set fonksiyonlarında hedef indeks olarak kullanılarak ilkel değerin diziye eklenmesini sağlar.


İlkel Tipler

Boolean

func xpc_bool_create(_ value: Bool) -> xpc_object_t
func xpc_bool_get_value(_ object: xpc_object_t) -> Bool

// Sabitler
var XPC_BOOL_TRUE: xpc_object_t   // true değerini temsil eden sabit
var XPC_BOOL_FALSE: xpc_object_t  // false değerini temsil eden sabit

Tam Sayılar

// İşaretli 64-bit
func xpc_int64_create(_ value: Int64) -> xpc_object_t
func xpc_int64_get_value(_ object: xpc_object_t) -> Int64

// İşaretsiz 64-bit
func xpc_uint64_create(_ value: UInt64) -> xpc_object_t
func xpc_uint64_get_value(_ object: xpc_object_t) -> UInt64

Kayan Nokta

func xpc_double_create(_ value: Double) -> xpc_object_t
func xpc_double_get_value(_ object: xpc_object_t) -> Double

String (Dize)

func xpc_string_create(_ string: UnsafePointer<CChar>) -> xpc_object_t
func xpc_string_create_with_format_and_arguments(_ fmt: ..., _ args: ...) -> xpc_object_t
func xpc_string_get_length(_ object: xpc_object_t) -> Int
func xpc_string_get_string_ptr(_ object: xpc_object_t) -> UnsafePointer<CChar>?

Veri (Data)

func xpc_data_create(_ bytes: UnsafeRawPointer?, _ length: Int) -> xpc_object_t
func xpc_data_create_with_dispatch_data(_ data: dispatch_data_t) -> xpc_object_t
func xpc_data_get_bytes(_ data: xpc_object_t, _ buffer: ..., _ offset: Int, _ length: Int) -> Int
func xpc_data_get_bytes_ptr(_ data: xpc_object_t) -> UnsafeRawPointer?
func xpc_data_get_length(_ data: xpc_object_t) -> Int

Tarih (Date)

func xpc_date_create(_ interval: Int64) -> xpc_object_t
func xpc_date_create_from_current() -> xpc_object_t
func xpc_date_get_value(_ date: xpc_object_t) -> Int64

UUID

func xpc_uuid_create(_ uuid: UnsafePointer<UInt8>) -> xpc_object_t
func xpc_uuid_get_bytes(_ uuid: xpc_object_t) -> UnsafePointer<UInt8>?

Dosya Tanıtıcı (File Descriptor)

func xpc_fd_create(_ fd: Int32) -> xpc_object_t?
func xpc_fd_dup(_ fd_object: xpc_object_t) -> Int32

Paylaşılan Bellek (Shared Memory)

// Belirtilen paylaşılan bellek bölgesini temsil eden XPC nesnesi oluştur
func xpc_shmem_create(_ region: UnsafeMutableRawPointer, _ length: Int) -> xpc_object_t

// Paylaşılan bellek nesnesinin bölgesini çağıranın adres alanına eşle
func xpc_shmem_map(_ shmem: xpc_object_t, _ region: ...) -> Int

Null

func xpc_null_create() -> xpc_object_t

Hata Tipleri

XPCRichError (Swift)

Yapı | XPC

*iOS 17.0+, macOS 14.0+*

Bir açıklama içeren ve hataya neden olan işlemin yeniden denenip denenemeyeceğini gösteren hata tipi.

struct XPCRichError

Özellikler ve yöntemler:

  • var description: String — Hata açıklaması
  • var isRetryable: Bool — İşlem yeniden denenebilir mi?

C Hata Sabitleri

| Sabit | Açıklama | | --- | --- | | XPC_ERROR_KEY_DESCRIPTION | Hata sözlüğünden okunabilir açıklama almak için anahtar | | XPC_ERROR_PEER_CODE_SIGNING_REQUIREMENT | Eş kod imzalama gereksinimi karşılanmadığında |