I have 30 Rooms and each Room should have 5 same RoomAttributes.
I have a many to many relationship between Room and RoomAttributes.
My Solutions was, to create 30 * 5 = 150 RoomAttributes and make NSSet’s of RoomAttributes for every Room. This is allot of work.
How i creat a Room:
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";
How i create 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];
How i create the NSSet:
NSSet *attributeFurRaum = [NSSet setWithObjects:attribute1, attribute2,nil];
raum.raumattribute = attributeFurRaum;
How can i make this easier?
**EDITED
ahh I see – sorry I misunderstood the original question – the edit makes it easier.
For that I would create three helper methods
then you could store your pre-determined object data in a plist or JSON – parse it into a dictionary then go something like: