IntersectSet 関数を使用して一連の数値を比較するために、NSSet と NSMutable セットを使用しようとしています。ただし、整数を使用することで型に逆らっていると思います。NSSet を作成し、IntersectsSet 関数を整数に使用する方法はありますか。これを完全に達成する別の方法はありますか?
コード スニペットを次に示します。
NSSmutableArray *compareRow [[NSMutableArray alloc] init];
NSSet *A_Table = [[NSSet alloc] initWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"11", @"12",nil];
//...
//Reading some data from a file.
//Populate the tables with the third arrays
[currentHistoryRow addObject:[NSNumber numberWithInt:post1]];
[currentHistoryRow addObject:[NSNumber numberWithInt:post2]];
[currentHistoryRow addObject:[NSNumber numberWithInt:post3]];
[currentHistoryRow addObject:[NSNumber numberWithInt:post4]];
[currentHistoryRow addObject:[NSNumber numberWithInt:post5]];
NSSet *compareRow = [[NSSet alloc] initWithArray:currentHistoryRow];
if ([compareRow intersectsSet:A_Table]) {
// You'll see this message
NSLog(@"subset present");
}
A_Table と compareRow は同じタイプではないため、条件が真になることはありません。