Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7876909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:14:35+00:00 2026-06-03T03:14:35+00:00

I have 30 Rooms and each Room should have 5 same RoomAttributes. I have

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:14:36+00:00Added an answer on June 3, 2026 at 3:14 am

    **EDITED

    ahh I see – sorry I misunderstood the original question – the edit makes it easier.

    For that I would create three helper methods

    -(RaumAttribute*)roomAttributeWithName:(NSString *)name andSchalter:(BOOL)schalter
    {
        Raumattribute *att =[NSEntityDescription insertNewObjectForEntityForName:@"Raumattribute" inManagedObjectContext:context];
        att.attributname = name;
        att.schalter = schalter;
        return att;
    }
    
    -(NSSet *)roomAttributes
    {
        NSArray *atts = [@"Beamer,Behindertengerecht" componentsSeparatedByString:@","];
        NSMutableSet *roomAttributes = [NSMutableSet set];
        for(NSString *name in atts)
        {
            [roomAttributes addObject:[self roomAttributeWithName:name andSchalter:NO]];
        }
        return roomAttributes;
    }
    
    -(Raum *)raumFromDictionary:(NSDictionary *)details
    {
        Raum *raum = [NSEntityDescription insertNewObjectForEntityForName:@"Raum" inManagedObjectContext:context];
        raum.raumName = [details valueForKey:@"raumName"];
        raum.etage = [details valueForKey:@"etage"];
        raum.beschreibung = [details valueForKey:@"beschreibung"];
        raum.raumpreis = [details objectForKey:@"raumpreis"];
        raum.raumname = [details objectForKey:@"raumname"];
        return raum;
    }
    

    then you could store your pre-determined object data in a plist or JSON – parse it into a dictionary then go something like:

    NSArray *raumDictionaries = //code to get array of dictionaries from a plist or whatever  source
    NSSet *raumAttributeSet = [self roomAttributes];
    for(NSDictionary *raumDict in raumDictionaries)
    {
        Raum *raum = [self raumFromDictionary:raumDict];
        raum.raumattribute = raumAttributeSet;
        //save context
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a collection of rooms. Each room is a document that
i have an nsset of room attributes(NSString), i stored them in CoreData. how can
I have an arraylist that contains items called Room. Each Room has a roomtype
All the in-browser chat rooms I have seen so far append messages into the
Within an asp.net MVC app, I'm trying to find rooms which have a guest/client,
I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
I have a dynamic page that gets a certain number of results for rooms
Say you have a website for users to search for hotel rooms for rent.
I am creating a tabbed pane for the amount of rooms that I have
I have a room class, which has 3 linked tables, Property , Sex (as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.