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 8338937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:44:42+00:00 2026-06-09T04:44:42+00:00

This is a sample of an array I would like to get value from

  • 0

This is a sample of an array I would like to get value from it.

coursesArray = [[NSMutableArray alloc]init];

// AR111:
[coursesArray addObject:[[NSMutableDictionary alloc] initWithObjectsAndKeys:
                           @"MUR",@"courseType",  
                           @"AR111",@"courseCode",
                           @"Arabic Communication Skills (I)",@"courseName",
                           @"3",@"creditHours",
                           @"",@"preRequisites",
                           @"63.000",@"coursePrice",
                           @"6.000",@"courseEPP",
                           @"This course aims at .",@"courseDetails",
                           nil]];

And this is my code to get the value to it.

NSManagedObjectContext *context = [self.fetchedResultsController managedObjectContext];
NSEntityDescription *entity = [[self.fetchedResultsController fetchRequest] entity];

int i = 0;
for (i = 0; i < [coursesArray count] ; i++) {

NSManagedObject *newManagedObject = [NSEntityDescription insertNewObjectForEntityForName:[entity name] inManagedObjectContext:context];

    [newManagedObject setValue:[[coursesArray objectAtIndex: i ]forKey:@"courseName"] forKey:@"courseName"];
}

If any one can help me to correct the following part:

[newManagedObject setValue:[[coursesArray objectAtIndex: i ]forKey:@"courseName"] forKey:@"courseName"];

The values will be add in to core data forKey:@”courseName”.

  • 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-09T04:44:43+00:00Added an answer on June 9, 2026 at 4:44 am
    [newManagedObject setValue:[[coursesArray objectAtIndex: i ]forKey:@"courseName"] forKey:@"courseName"];
    

    This is a classic case of putting too much code on one line, I think. I don’t expect this actually compiles?

    Let’s try and break it down into sections. I’ve taken the central bit of code out and replaced it with XX:

    [newManagedObject setValue:XX forKey:@"courseName"];
    

    This bit looks fine. setValue:forKey is a valid method for a managed object.

    XX is:

    [YY forKey:@"courseName"]
    

    It’s not clear if this is right or not, but it doesn’t look good – the method name doesn’t seem right.

    YY is:

    [coursesArray objectAtIndex:i]
    

    This is fine, and it returns a mutable dictionary. But dictionaries don’t implement a method called forKey:. They do implement a method called objectForKey:, though, which is what you want.

    So, your corrected line should be:

    [newManagedObject setValue:[[coursesArray objectAtIndex:i] objectForKey:@"courseName"] forKey:@"courseName"];
    

    If you’re writing a lot of code like this, custom objects with properties to hold data members suddenly make a lot more sense. The forKey: all over the place soon becomes unreadable.

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

Sidebar

Related Questions

I would like to know how to get the values into this array. Can
I have an array that looks like this (sample): Array ( [1600] => Array
When I try to use this in my Javascript prototype like so: Array.prototype.sample =
This would be easy to do with regular array with a simple for statement.
This question is probably easy to solve, but here it comes. I would like
I have an array of 16 squares and I would like to auto complete
We would like to get the result with full information, like Unique = Value1,
I'm a starting iOS developer and I would like to get the idea of
This is my simple array: typeset -A foo foo[first]=first Value foo[second]=second Value And I
Code-wise this seems so simple, but I still get stuck on a #VALUE. I

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.