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

  • Home
  • SEARCH
  • 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 8113731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:55:28+00:00 2026-06-06T02:55:28+00:00

Hi i am saving values coming from a database in a MultableArray and then

  • 0

Hi i am saving values coming from a database in a MultableArray and then in CoreData:

 NSMultableArray *mutary = [[NSMultableArray alloc] init];
      NSManagedObjectContext *context = [app managedObjectContext];
    for(int n=0; n<[AttributeArray count]; n++)
    {

    [mutary addObject:[[AttributeArray objectAtIndex:n] objectForKey:@"AttributName"]];
    NSLog(@"%@", mutary);
}
attributeString = [mutary componentsJoinedByString:@","];

 raume = [NSEntityDescription insertNewObjectForEntityForName:@"Raum" inManagedObjectContext:context];

raume.raumattribut = attributeString;

 if (![context save:&error]) {
 NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
 abort();

}

NSLog output for the MultableArray is:

    2012-06-20 17:21:00.047 book-app[31984:15803] (
    A7OVERHEAD,
    Beamer
)

So far its working correct. The two expected values from the database are now in the Array.
Now i am fetching these attributes from CoreData:

    NSManagedObjectContext *context = [app managedObjectContext];
    NSFetchRequest *request = [[NSFetchRequest alloc] init];
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Raum" inManagedObjectContext:context];
    [request setEntity:entity];
    NSError *error = nil;
    NSArray *events = [context executeFetchRequest:request error:&error];

for (Raum *att in events)
    {
     stringAttribute = [[events valueForKey:@"raumattribut"] componentsJoinedByString:@","];
     NSLog(@"ATTRIBUTE: %@", stringAttribute);
    }
}

So far so good. But if i look now on my NSLog output:

2012-06-20 17:21:00.055 book-app[31984:15803] ATTRIBUTE: <null>,A7OVERHEAD,Beamer

CoreData is returning and then the two values. Where is that coming from?

Can someone help?

Thanks in advance

  • 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-06T02:55:30+00:00Added an answer on June 6, 2026 at 2:55 am

    EDIT: After some investigating and clarifying (see comments), here is my answer:
    Calling valueForKey on an NSArray returns an array where each element is created by calling valueForKey on each member of the original array. This means your output indicates that you have 3 total objects returned by your fetch request, and the first one does not have it’s raumattribut attribute set.

    PREVIOUS ANSWER:
    You are calling valueForKey on an instance of NSArray (the query results). Perhaps you need to get objectAtIndex:0 first use the variable you are iterating the values on? valueForKey is likely returning nil.

    stringAttribute = [[att valueForKey:@"raumattribut"] componentsJoinedByString:@","];
    

    or similar.

    EDIT:
    At first I missed the for loop in the second part, I have edited the above code sample to use the attr, which

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hey there, so in a msSQL database that i'm saving and retrieving from using
I am saving the gamestate from a mobile game on a MySql database. The
This is regarding my other question: Saving Latitude and Longitude values to a MySQL
AI have a slider, I'm saving it's value to user defaults, and then grabbing
I am saving a TimeSpan (from .NET) value in my db as BIGINT in
Saving a Word 2003 document to XML and then back results in a reduced
I have a session class where i am saving text box values(application) in a
I'm saving a list of images (from a gallery) to a device using LocalStorage.
I'm having trouble saving an entity into an SQL Server 2005 database. I'm using
I am saving values in two tables asset and asset_history.On creating asset i am

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.