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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:33:43+00:00 2026-05-25T23:33:43+00:00

so i have an array of custom objects. i want to go through them

  • 0

so i have an array of custom objects. i want to go through them to find the maxx, maxy, minx, and miny values. i need the largest of the maxes and smallest of the mins. the following code makes complete sense to me, but i tend to get a random value from the list, my maxes do not get the max or min, and the mins do not get the min or the max.

so, i take the first values from the first object in the array, i then compare each objects values to my current maxx, maxy, minx, miny to see if the object’s values are larger or less then, and if so, assign it:

        claimCenterBoundary = [dataCenter.claimCenterBoundaryList objectAtIndex:0];
        maxx = claimCenterBoundary.maxx;
        maxy = claimCenterBoundary.maxy;
        minx = claimCenterBoundary.minx;
        miny = claimCenterBoundary.miny;

        for (int i = 0; i < count; i++) 
        {
            claimCenterBoundary = [dataCenter.claimCenterBoundaryList objectAtIndex:i];
            NSLog(@"minx: %@ miny: %@ maxx: %@ maxy: %@", claimCenterBoundary.minx, claimCenterBoundary.miny, claimCenterBoundary.maxx, claimCenterBoundary.maxy);

            if (maxx < claimCenterBoundary.maxx)
                maxx = claimCenterBoundary.maxx;

            if (maxy < claimCenterBoundary.maxy)
                maxy = claimCenterBoundary.maxy;

            if (minx > claimCenterBoundary.minx)
                minx = claimCenterBoundary.minx;

            if (miny > claimCenterBoundary.miny)
                miny = claimCenterBoundary.miny;
        }

here is my output:

count: 8
minx: -98.9139404296875 miny: 48.51737594604492 maxx: -98.90547943115234 maxy: 48.52248382568359
minx: -98.9139404296875 miny: 48.51737594604492 maxx: -98.90547943115234 maxy: 48.52248382568359
minx: -98.92726898193359 miny: 48.51534652709961 maxx: -98.91975402832031 maxy: 48.52249908447266
minx: -98.92726898193359 miny: 48.51534652709961 maxx: -98.91975402832031 maxy: 48.52249908447266
minx: -98.92340850830078 miny: 48.51531219482422 maxx: -98.91383361816406 maxy: 48.52248382568359
minx: -98.92340850830078 miny: 48.51531219482422 maxx: -98.91383361816406 maxy: 48.52248382568359
minx: -98.909423828125 miny: 48.51529693603516 maxx: -98.90548706054688 maxy: 48.51742553710938
minx: -98.96006774902344 miny: 48.51530075073242 maxx: -98.94926452636719 maxy: 48.52977752685547
final minx :-98.92726898193359 miny: 48.51531219482422 maxx: -98.94926452636719 maxy: 48.52977752685547

i can not figure out why this code would not work.

  • 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-05-25T23:33:44+00:00Added an answer on May 25, 2026 at 11:33 pm

    This line…

    NSLog(@"minx: %@ miny: %@ maxx: %@ maxy: %@", claimCenterBoundary.minx, claimCenterBoundary.miny, claimCenterBoundary.maxx, claimCenterBoundary.maxy);
    

    … implies that the return values of -minx, -miny, -maxx, -maxy are all objects, and most likely NSNumber objects.

    If that’s the case, then you can’t use < and > to compare two NSNumbers. You’d be doing pointer comparison, which is most definitely not what you want.

    So what you could do instead is this:

    NSArray *objects = dataCenter.claimCenterBoundaryList;
    NSNumber *minx = [objects valueForKeyPath:@"@min.minx"];
    NSNumber *miny = [objects valueForKeyPath:@"@min.miny"];
    NSNumber *maxx = [objects valueForKeyPath:@"@min.maxx"];
    NSNumber *maxy = [objects valueForKeyPath:@"@min.maxy"];
    

    This is technically 4 times less efficient than your original proposal, since you’re going to iterate the entire list 4 times instead of once, but if your list is a reasonable size, then the difference is probably negligible.

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

Sidebar

Related Questions

I have an array of custom objects. MyCustomArr[]. I want to convert this to
I have a mutable array of custom objects. I want to filter that array
I have an array of custom class Student objects. CourseStudent and ResearchStudent both inherit
I have a method that is adding custom objects to an array in a
I have an array of custom objects. The objects includes a dictionary. Something like
My Situation: I have an NSDictionary object. Keyed by NSNumber. Values are custom objects.
In a PHP program I have an array of some custom objects, and I
I have an array of objects which created from a custom class. The custom
I have an array of objects and I want to concatenate it with another
Hi I have an array of dynamic type which i want to iterate through.

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.