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

The Archive Base Latest Questions

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

I have an array (items) of custom class objects (catalogItem) each catalogItem has various

  • 0

I have an array (items) of custom class objects (catalogItem) each catalogItem has various properties one of which is an mastering called caption

I’m trying to update this catalogItem.caption in each catalogItem in the items array from nsstrings in the second array (tempCaption)

I know to iterate through the arrays but I can’t seem to get the syntax right because what I seem to be doing is each catalogItem.caption cycles through each nsstring in the tempCaption array. So it iterates like 49 times instead of the 7 it should. catalogItem.caption all end up being the last item in the tempCaption array.

ViewController.m

-(void)parseUpdateCaptions
{
NSMutableArray *tempCaptions = [NSMutableArray array];
//get server objects
PFQuery *query = [PFQuery queryWithClassName:@"UserPhoto"];
NSArray* parseArray = [query findObjects];
    //fast enum and grab strings and put into tempCaption array
       for (PFObject *parseObject in parseArray) {
        [tempCaptions addObject:[parseObject objectForKey:@"caption"]];
    }


//fast enum through each array and put the capString into the catalogItem.caption slot
//this iterates too much, putting each string into each class object 7 times instead of just putting the nsstring at index 0 in the temCaption array into the catalogItem.caption at index 0, etc. (7 catalogItem objects in total in items array, and 7 nsstrings in tempCaption array)
for (catalogItem in items) {
    for (NSString *capString in tempCaptions) {
            catalogItem.caption = capString;
            DLog(@"catalog: %@",catalogItem.caption);
        }
}

}

if needed – class object header.h

#import <Foundation/Foundation.h>

@interface BBCatalogClass : NSObject


@property (nonatomic, strong) NSData *image;
@property (nonatomic, strong) NSData *carouselImage;
@property (nonatomic, strong) NSString *objectID;
@property (nonatomic, strong) NSString *caption;
@end
  • 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-06T05:24:05+00:00Added an answer on June 6, 2026 at 5:24 am

    I would try traditional for looping instead of fast enumeration. This will work if I understand you correctly, that the indexes of the two arrays are aligned.

    for(int i = 0; i<items.count; i++) {
      catalogItem = [items objectAtIndex:i]; 
      catalogItem.caption = [tempCaptions objectAtIndex:i];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array Items which has 10 elements. I need to remove the
I have a NSTreeController which array is bound to a items (custom) property of
I have a custom class CurvePoint which I define a set of data items
So I have an array of items, which I am iterating through and grabbing
I have an array that has 22 items in it (it may also have
I have an array which contains sets of three similar named items; however, sometimes
I have a property which is an array of items, but when I come
I have a grid view which is populated using a custom ImageAdapter class extending
I have a custom Array Adapter to display a list of items, in this
I have a listview with a custom array adapter: public class SmsMessageAdapter extends ArrayAdapter<ContactMessage>

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.