私は顧客情報を保存するために私のプログラムにコアデータを実装しています。各エンティティ "CustomerInformation"を呼び出してみましょう。各 "CustomerInformation"エンティティには、 "count"、 "property2"、および "property3"の3つのプロパティがあります。countは、その特定のエンティティの番号識別子です。
だから私は "CustomerInformation" を削除する場合(2)、他の2つは自分のカウントを保持します
CustomerInformation
-count //for example, this would be "1"
-property2
-property3
CustomerInformation
-count //for example, this would be "2"
-property2
-property3
CustomerInformation
-count //for example, this would be "3"
-property2
-property3
...のは、私は三つの "CustomerInformation" の実体を持っているとしましょう。私がこの時点で行う必要があるのは、すべてのエンティティ(この場合は3つ)をループし、欠落している値がどこにあるかを確認することです(「CustomerInformation」(2)を削除した場合は2が欠損値になります)。
これは私の考えですが、私はそれを完了するための助けが必要です。注:
NSFetchRequest *custRequest = [[NSFetchRequest alloc] init];
ProjectAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *custContext = [appDelegate managedObjectContext];
NSEntityDescription *customerInformation = [NSEntityDescription entityForName:@"CustomerInformation"
inManagedObjectContext:custContext];
[custRequest setEntity:customerInformation];
NSError *error;
NSArray *array = [custContext executeFetchRequest:custRequest error:&error];
for (int n=0; n<=7; n++)
{
//here I need it to go through and find the missing 2
}
私はこれらの7つのものを持っていて、3番を削除すると、どうすればこのことを把握できますか? NSUserDefaultsのNSArray? (私はちょうど私自身のコメント - 質問に答えたかもしれません - あなたが何か良いことを知っているかどうか私に知らせてください)。 – Baub
私は自分自身の質問に答え、それを実装しました。正しい方向へのリードに感謝します。 – Baub