UA-17470720-3

Jump to content


Photo
- - - - -

Rearranging the cells of the table and fetching their order

models core-data

  • Please log in to reply
3 replies to this topic

#1 fabiensen

fabiensen

    Jr. Member

  • STV 4.0 Std
  • PipPip
  • 23 posts
Reputation: 5
Good

Posted 27 April 2016 - 08:56 AM

Hi,

 

talking about the feature to reorder items in STV 4.x (as it is explained in the manual), anyway I rearrange cells and then I fetch data in the code, I have always the same order (order is the attribute of the entity, as explained in the manual). This can be the initial situation:

 

- English

- German

- Italian

 

If I rearrange the cells manually in the app, I can have this situation:

 

- Italian

- English

- German

 

but when I fetch data with:

 

for (i = 0; i < arrayOfTheEntity.count; i++) {

            NSLog (@"Element %i = %@", i, [[returnArray2 objectAtIndex: i] valueForKey:@"order"]);

            NSLog (@"Element %i = %@", i, [[returnArray2 objectAtIndex: i] valueForKey:@"language"]);

        }

 

I got the same situation as the first time:

 

- English (order:0)

- German (order:1) 

- Italian (order:2)

 

although I see something else.

 

So, the question is: when I reorder the cells, where is their real index stored? The entity does not seem to hold it through the order attribute, which seems not to change.

 

Thanks for your help

Fabio



#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 27 April 2016 - 09:13 AM

Hi Fabio,

 

If these are stored in an NSMutableArray, then rearranging them in the UI will modify this array to reflect the new order.



#3 fabiensen

fabiensen

    Jr. Member

  • STV 4.0 Std
  • PipPip
  • 23 posts
Reputation: 5
Good

Posted 27 April 2016 - 10:12 AM

Hi Tarek

 

thanks for your quick reply.

I followed the tutorial in the manual actually, where order is indicated as an attribute of type int. I understand what you say, just I'd like to know if there are chances to handle this by STV or should I find the solution in plain Obj-c.

 

Thank you very much!

Fabio



#4 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 28 April 2016 - 07:25 AM

Hi Fabio,

 

I am afraid I don't quite understand your question. If you're using Core Data, then STV will automatically fill in the 'order' attribute to maintain whatever custom order your user has set. If you're storing your objects in an NSMutableArray instead, STV will still automatically rearrange it. Does that answer your question?







Also tagged with one or more of these keywords: models, core-data

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users