Cocoaメモ

Appleプラットフォームでの開発メモ

2021-05-01から1ヶ月間の記事一覧

NSPersistentContainerのsqliteファイルパスをカスタマイズする

基本 let container = NSPersistentContainer(name: "Sample") NSPersistentContainer.init(name:) By default, the provided name value is used to name the persistent store and is used to look up the name of the NSManagedObjectModel object to be …

NSPersistentContainer.loadPersistentStoresのcompletionHandlerはデフォルトで同期的に呼ばれる

NSPersistentContainer.loadPersistentStores(completionHandler:)のcompletionHandlerは、デフォルトではloadPersistentStoresを抜ける前に同期的に呼ばれます。 理由 NSPersistentContainer.persistentStoreDescriptions[0].shouldAddStoreAsynchronously…

Core DataとiCloudの統合年表

iOS 13 Core DataとCloudKitを統合したNSPersistentCloudKitContainerが追加された Using Core Data With CloudKit - WWDC 2019 - Videos - Apple Developer iOS 10 NSPersistentContainerが追加された What's New in Core Data - WWDC 2016 - Videos - Appl…

Lightweight MigrationのManaged Object Modelは最新の一つだけ保持すればよいらしい

Core Dataで、Lightweight Migration で済む場合、アプリが持つManaged Object Modelは最新の一つだけでよいようです。 つまり、次のように、複数のモデルを持つ必要がありません。 xcdatamodeldに最新のバージョンのxcdatamodelだけを持つか、単純にxcdatam…

iOS Simulatorで、複数アイテムをドラッグする方法

検証環境 Xcode 12.5 手順 ドラッグ操作を開始する ctrlキーを押しながら、マウスボタンを離す マウスボタンを離したら、ctrlも離してよい マウスボタンを離した位置に、1本目の指を押しっぱなしにしていることを示す円が表示される 次からのマウスボタンタ…

Xcode WorkspaceでアプリプロジェクトとSwift Packageを束ねる

Xcode Workspace(xcworkspace)には複数のXcode Projectを束ねて、暗黙の依存関係を持たせる機能があります。 Xcode Workspace (Xcode Concepts) 例えば、アプリ本体のxcodeprojとライブラリのxcodeprojをWorkspaceで束ねると、アプリ本体側からライブラリxco…