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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T11:38:58+00:00 2026-06-09T11:38:58+00:00

Coming from C++, here’s my question : I have created objects of this type

  • 0

Coming from C++, here’s my question :

I have created objects of this type :

    Size *one = [[Size alloc] initWithX: 3 andY: 1];
    Size *two = [[Size alloc] initWithX: 4 andY: 7];
    // etc...
    Size *thirtythree = [[Size alloc] initWithX: 5 andY: 9];

( with a @property int x; & @property int y; for each object.. )

that I have stored in an array as follows :

NSArray *arrayOfSizes;

arrayOfSizes = [NSArray arrayWithObjects:one,two,three,four,five,six,
                seven,eight,nine,ten,eleven,twelve,thirteen,
                fourteen,fifteen,sixteen,seventeen,eighteen,
                nineteen,twenty,twentyone,twentytwo,
                twentythree,twentyfour,twentyfive,twentysix,
                twentyseven,twentyeight,twentynine,thirty,
                thirtyone,thirtytwo,thirtythree nil];

now I have a single object of type :

Myobject *myObject = [[Myobject alloc] initWithX: 5 andY: 3];

that also has a @property int x; & @property int y; …

and I want to compare its values to the values of the objects found in the array, until I find an array object of similar values.. But I don’t know how to do that in Obj-C. (in c++ I would simply use a vector v; with v.size(); and v[x]; ..etc… I suppose..)

here’s what I’m looking for.. 🙂

while( !wholeOfArrayOfSizesChecked && !found)
{
    if ( // x & y of object in array is equal to x & y of myObject )
    {
        found = YES;
    }
    else if( // whole of array checked)
    {
       wholeOfArrayOfSizesChecked = YES;
    }
    else
    { 
      //move on to the next object of the array..
    }
}

Thanks in advance for any help!

  • 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-09T11:38:59+00:00Added an answer on June 9, 2026 at 11:38 am

    Just to use your given structure. There are smarter ways of doing it though 🙂

    wholeOfArrayOfSizesChecked = NO; 
    int currObj = 0  
    while( !wholeOfArrayOfSizesChecked && !found)
    {
        Size *current = (Size *)[arrayOfSizes objectAtIndex:i];
        if (myObject.x == current.x && myObject.y == current.y)
        {
            found = YES;
        }
        else if(currObj == [arrayOfSizes count] -1 )
        {
           wholeOfArrayOfSizesChecked = YES;
        }
        else
        { 
          currObj++;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Coming from this question , I have a wxComboCtrl with a custom popup made
I have implemented UIWebView and displaying the contents coming from web services,Here is the
(LocalVariable)ABC.string(Name) = (IDataReader)dataReader.GetString(0); This name value is coming from database. What happening here is
Using information from some of the questions here on generic views, I have created
Edit: If you're coming here from Google, this issue is a result of the
here's what i'm trying to do. I have a variable coming from a PHP
I'm having trouble with this query. I have 2 date coming from textboxes (don't
SVN newbie (although so far I really like it (coming from CVS) Ok, here's
I am using jQuery to get data from server. Data is coming. Here what
Windows Phone 7.1/7.5/Mango Silverlight App. Coming from here: Need clarification on using audio on

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.