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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:42:14+00:00 2026-05-17T01:42:14+00:00

counter = [myArray count]; for (i = 0 ; i < count ; i++)

  • 0
counter = [myArray count];
for (i = 0 ; i < count ;  i++) {
     [[anotherArray objectAtIndex:i] setTitle:[myArray objectAtIndex:i]];
}

I would like to do it the objective C 2.0 way but can’t seem to find how to access the index ‘i’ (if that’s possible anyway).

for (NSString *myString in myArray) {
     [[anotherArray objectAtIndex:i] setTitle: myString];
}

(Please forgive any typos; I’m currently not behind my Mac so this is out of my head.)

  • 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-17T01:42:15+00:00Added an answer on May 17, 2026 at 1:42 am

    To do this you have to keep track of the index yourself:

    NSUInteger index = 0;
    for (NSString *myString in myArray) {
        [[anotherArray objectAtIndex: index] setTitle: myString];
        ++index;
    }
    

    Maybe in this case an old-fashioned for loop with an index is the better choice though. Unless you are trying to use fast enumeration for performance reasons here.

    But it would be probably even better to restructure the code so that you don’t have to copy the strings from myArray to the title property of the objects in anotherArray manually.

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

Sidebar

Related Questions

I added a counter cache but can't get it to update. But I can
Here's my code: int myArray[]={1,2,3,4,5,6,7,8}; for(int counter=myArray.length; counter > 0;counter--){ System.out.println(myArray[counter]); } I'd like
My counter function looks like that function count() { var value = ids.val(); return
Given the following code : for (int i=0; i<n; i++) { counter += myArray[i];
Why is it counter intuitive? /(?<!\d)\d{8}(?!\d)/ , here (?<!\d) comes first , but called
I have a counter hash that I am trying to sort by count. The
I made a simple counter, but it increments by 2 instead of 1. $handle
I have a phrase counter function as part of a class that I would
If I put counter at OnCreate() , then it will count how many times
I have implemented a counter using NobleCount like this: $('#message').NobleCount('#messageInfo',{ max_chars: max, block_negative: true

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.