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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T16:48:54+00:00 2026-05-20T16:48:54+00:00

This function works well, but it always returns the same value because I don’t

  • 0

This function works well, but it always returns the same value because I don’t know how to work with the objectatindex. And this:

NSLog (@"Object at index %d is: %@", i, [appDelegate.animals objectAtIndex: i]);

Returns this:

2011-03-20 14:38:07.365 Tutorial[5063:207] Object at index 0 is: <Animals: 0x6151a20>
2011-03-20 14:38:07.367 Tutorial[5063:207] Object at index 1 is: <Animals: 0x6151ba0>
2011-03-20 14:38:07.368 Tutorial[5063:207] Object at index 2 is: <Animals: 0x6151d20>
2011-03-20 14:38:07.371 Tutorial[5063:207] Object at index 3 is: <Animals: 0x6151e90>
2011-03-20 14:38:07.374 Tutorial[5063:207] Object at index 4 is: <Animals: 0x6151ff0>
2011-03-20 14:38:07.375 Tutorial[5063:207] Object at index 5 is: <Animals: 0x6152180>

This is my full code: I actually have to combine the things in the for function.

int i = 0;
int count;

TutorialAppDelegate *appDelegate = (TutorialAppDelegate *)[[UIApplication sharedApplication] delegate];
Animals *aAnimal = (Animals *)[appDelegate.animals objectAtIndex:i];

count = [appDelegate.animals count];


for (i = 0; i < count; i++)
{
    // returns the right value, but always the same because no objectAtIndex
    NSLog(@"%@",aAnimal.animalName);


    NSLog (@"Object at index %d is: %@", 
           i, [appDelegate.animals objectAtIndex: i]);




}
  • 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-20T16:48:55+00:00Added an answer on May 20, 2026 at 4:48 pm

    Have you tried:

    for (i = 0; i < count; i++) {
        Animals* nextAnimal = (Animals*)[appDelegate.animals objectAtIndex: i];
        NSLog (@"Object at index %d is: %@", 
               i, nextAnimal.animalName);
    }
    

    The reason you’re seeing stuff like:

    1-03-20 14:38:07.365 Tutorial[5063:207] Object at index 0 is: <Animals: 0x6151a20>
    2011-03-20 14:38:07.367 Tutorial[5063:207] Object at index 1 is: <Animals: 0x6151ba0>
    2011-03-20 14:38:07.368 Tutorial[5063:207] Object at index 2 is: <Animals: 0x6151d20>
    2011-03-20 14:38:07.371 Tutorial[5063:207] Object at index 3 is: <Animals: 0x6151e90>
    2011-03-20 14:38:07.374 Tutorial[5063:207] Object at index 4 is: <Animals: 0x6151ff0>
    2011-03-20 14:38:07.375 Tutorial[5063:207] Object at index 5 is: <Animals: 0x6152180>
    

    …is because you’re logging the entire object, and not just the name. But you can see that a different object is indeed being returned each time by looking at the memory address of each one (the part that looks like 0x615....).

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

Sidebar

Related Questions

This function works fine: std::string get_str() { return std::get<0>( make_tuple(std::string(hi)) ); } But if
This function works fine if I disable errors. But I have to solve them.
This matrix transposition function works, but I'm trying to understand its step by step
I have this function and it works fine to get a translated value from
This function works as it should, window.setInterval(function(){ var active = $('#frontpageControls a.active'); var next
Can someone elaborate how this function works? Does it load every time from disk
This function only works once, when I click an anchor element again, nothign happens.
Hi am using this function that works by a single ID ( 52000121 )
I do not see how this recursive function works: function f(n) { g(n-1) }
I have this jquery function that works, except I need to add something. 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.