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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:01:24+00:00 2026-06-17T05:01:24+00:00

I have a array fetched from the core data and trying to do some

  • 0

I have a array fetched from the core data and trying to do some simple calculation but getting errors of Invalid operations to binary expression

pop_cum[i]= (pop_ln_array[i-1] + pop_ln_array[i]);
//getting error at this point of "Invalid operations to binary expression('id' and 'id')

I know we have to change the type of the array values into int but how?

NSManagedObjectContext *moc = [self managedObjectContext];

NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Input_Details" inManagedObjectContext:moc];

NSFetchRequest *request = [[NSFetchRequest alloc] init];

[request setEntity:entityDescription];

// Set example predicate and sort orderings...
request.propertiesToFetch = @[ @"pop_Ln" ];

request.resultType = NSDictionaryResultType;
//if you change the sort order here, please change it to SDInputDetailsList also
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc]
                                    initWithKey:@"sewer_No" ascending:YES];
[request setSortDescriptors:@[sortDescriptor]];

NSError *error;
NSArray *pop_ln_array = [moc executeFetchRequest:request error:&error];
int arrayCount=[pop_ln_array count];
//Calculating cumulative population, flow & peak factor
NSLog(@"arrayCount is %d",arrayCount);
if (pop_ln_array == nil)
{
    NSLog(@"Cumilative population line array is nil");
}
else
{
   NSArray *pop_cum[arrayCount];
    for(int i=0;i<[pop_ln_array count];i++)
    {
        NSLog(@"Cumilative array at %d is %@",i,pop_ln_array[i]);
        if (i==0)
        {
            pop_cum[i]=pop_ln_array[i] ;
        }
        else
        {
            pop_cum[i]= (pop_cum[i-1] + pop_ln_array[i]);    //getting error at this point of "Invalid operations to binary expression('id' and 'id')
        }

    }
}
  • 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-17T05:01:25+00:00Added an answer on June 17, 2026 at 5:01 am

    Use as follows

    for(int i=0;i<[pop_ln_array count];i++){
        NSLog(@"Cumilative array at %d is %@",i,pop_ln_array[i]);
        if (i==0){
                pop_cum[i]=pop_ln_array[i];
                NSLog(@"pop_cum[%d] %@",i,pop_cum[i]);
    
         }
         else {
                NSLog(@"Pop_cum %@",pop_cum[i-1]);
                [pop_ln_array[i]intValue]);
                NSInteger first=[pop_ln_array[i-1]intValue], second=[pop_ln_array[i]intValue];
                NSInteger sum=first+second;
    
                pop_cum[i]=[NSString stringWithFormat:@"%d",sum];
    
            }
    }
    

    You are adding two ids. Which can not be.

    Convert it to integerValue or intValue or any numerical and then add.

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

Sidebar

Related Questions

I have a problem related to an array data which fetched from an external
I have some Core Data entries which are all fetched and thrown into an
I have string that look like Array that fetched from other webservice like this
I have a byte array which contains an image fetched from the net. I
I have an array of objects which was fetched from a JSON (JSONP) file
I'm currently wrapping my head around some problem with Core Data. I have one
I have a class that retrieves data from core data and stores it into
I have to return data fetched from MySQL table into a php file as
I have an array with 36 rows which was fetched from CoreData. Each row
I have string array which is fetched from an external xml response. This string

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.