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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:27:02+00:00 2026-06-16T18:27:02+00:00

If the model data in an NSArray does not change, and you call reloadData

  • 0

If the model data in an NSArray does not change, and you call reloadData on the UICollectionView, do the cells appear in different spots?

I’m finding that if my NSArray holds Obj1, Obj2, Obj3, then at first, the UICollectionView correctly maps Obj1 to the first collectionViewCell, Obj2 to the second, etc. This is how it’s set up in the cellForRowAtIndexPath, as it uses indexPath.row to get the right Obj from the array.

However, when I call reloadData, all the objects are mapped to the wrong UICollectionViewCell (Obj1 ends up somewhere else, such as the second collectionViewCell, and Obj2 ends up as the third collectionViewCell, etc.)

Why does this happen? I didn’t find the reason in the documentation.


FURTHERMORE, I’m having the same problem when my model array does change. For example, if my NSArray is Obj1, Obj2, Obj3, and then new instances of the Objs are created and are now in a different order, such that the NSArray is Obj2, Obj3, Obj1… and then I call reloadData, I face the same problem.

Obj2 doesn’t map to the first UICollectionViewCell as it should, but instead mapped to a different UICollectionViewCell

Anyone know why this happens with UICollectionViews?

Thanks!

EDIT: Code for cellForRowAtIndexPath

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
MIAppCell* cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:@"MIAppCell" forIndexPath:indexPath];
// set model data
[cell setAppTitle:[(MIAppDO*)[self.apps objectAtIndex:indexPath.row] getAppTitle]];
return cell;
}
  • 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-16T18:27:03+00:00Added an answer on June 16, 2026 at 6:27 pm

    I figured out the problem.

    Earlier, I was dequeuing a cell and setting it’s new model data, but the model data wasn’t correctly reflecting in the subclassed UICollectionViewCell.

    I needed to override the setter methods for my properties that represent the model data for my subclassed UICollectionViewCell. In those overriden methods, I was able to update the appropriate views of the cell.

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

Sidebar

Related Questions

I want to return the Model (data) of a controller in different formats (JavaScript/XML/JSON/HTML)
I have a data model that represents a weekly order. Eg. my order might
In my core data model I have a Person entity that has a to
I have a core data model that has 3 entities. Driver, Manifest and Jobs.
I have a Core Data model entity NoteObject that has a transformable type arrayOfTags
I have a UITableView that is populated with cells by core data and an
I'm transitioning an existing data model that was previously stored in XML to Core
I have a BankAccount model class that contains data like account number, bank name,
I have a core data model that has a one to many relationship, there
The data model in my program has a number of discrete states, but 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.