30 の部屋があり、各部屋には 5 つの同じ RoomAttributes が必要です。
Room と RoomAttributes の間に多対多の関係があります。
私の解決策は、30 * 5 = 150 の RoomAttributes を作成し、すべての Room に対して RoomAttributes の NSSet を作成することでした。これが仕事の割り当てです。
ルームの作成方法:
Raum *raum = [NSEntityDescription insertNewObjectForEntityForName:@"Raum" inManagedObjectContext:context];
raum.raumName = @"Main";
raum.etage = @"2. Stock, Raum 1.203";
raum.beschreibung = @"Gut beleuchtet";
raum.raumpreis = [NSNumber numberWithDouble:210];
raum.raumname = @"Besprechungsraum";
RoomAttributes の作成方法:
Raumattribute *attribute =[NSEntityDescription insertNewObjectForEntityForName:@"Raumattribute" inManagedObjectContext:context];
attribute.attributname = @"Beamer";
attribute.schalter = [NSNumber numberWithBool:NO];
Raumattribute *attribute2 =[NSEntityDescription insertNewObjectForEntityForName:@"Raumattribute" inManagedObjectContext:context];
attribute2.attributname = @"Behindertengerecht";
attribute2.schalter = [NSNumber numberWithBool:NO];
NSSet の作成方法:
NSSet *attributeFurRaum = [NSSet setWithObjects:attribute1, attribute2,nil];
raum.raumattribute = attributeFurRaum;
どうすればこれを簡単にできますか?