3

コア データはマッピング モデルを推測できない?!
NSMappingModel *mappingModel = [NSMappingModel inferredMappingModelForSourceModel:sourceModel destinationModel:destinationModel エラー:&error];

エラーが報告されました Domain=NSCocoaErrorDomain Code=134190 「操作を完了できませんでした。(Cocoa エラー 134190.)」 UserInfo=0x6b9df80 {reason=Source and destination attribute types are incompatible, entity=Event, property=content}


Xcode 4.3.3 (コア データ (sqlite))
このプロジェクトは、NSURLIsExcludedFromBackupKey が設定された 1 つのデータベースと、/Documents に格納されたユーザー生成のものを含む別のデータベースにユーザー生成されていないコンテンツを含めるために、さまざまな構成でバージョニングをテストするように設定されています。フォルダ。

バージョン 1 に 1 つの構成 (デフォルト) があるため、データベース ファイルと 2 つのエンティティが次の形式である、バージョン管理されたコア データ モデルがあります。

構成
デフォルト イベント、サブ
イベント イベント
コンテンツ - NSString event_id - NSInteger16 サブイベント - 対多関係ターゲット サブイベント

SubEvent
コンテンツ - NSString subEvent_id - NSInteger16 イベント - to-One Relationship 対象イベント

Version2 は以下のように変更されます
Configuration
Default Event, SubEvent
Backup - SubEvent
NoBackup Event
Event
content - Transformable CipherStringTransformer
event_id - NSInteger16 subEvents - Fetched Property - event_id = $FETCH_SOURCE.event_id

SubEvent コンテンツ - NSString
subEvent_id - NSInteger16 イベント - フェッチされたプロパティ - event_id = $FETCH_SOURCE.event_id


source-/destinationMode で対応するプロパティを出力すると、次のようになります。

 po [[[[sourceModel entitiesByName] valueForKey:@"Event"] propertiesByName] valueForKey:@"content"]  
(id)(<NSAttributeDescription: 0x6b9ae30>),  
name content, isOptional 1, isTransient 0, entity Event, renamingIdentifier content, validation predicates (),  
warnings (),  
versionHashModifier (null)  
userInfo {},  
attributeType 700 , attributeValueClassName NSString, defaultValue (null)  

(lldb) po [[[[destinationModel entitiesByName] valueForKey:@"Event"] propertiesByName] valueForKey:@"content"]  
(id)(<NSAttributeDescription: 0x6e656b0>),  
name content, isOptional 1, isTransient 0, entity Event, renamingIdentifier content,  
validation predicates (),  
warnings (),  
versionHashModifier (null)  
userInfo {},  
attributeType 1800 , attributeValueClassName CipherTextTransformer, defaultValue (null)  

NSString から Transformable への切り替えのみがあれば、傍受なしで LightWeightMigration になりますが、新しい構成では不可能です。

4

0 に答える 0