UITableView Core Data reordering (next) - uitableview

UITableView Core Data reordering
I'm having troubles with the solution above. If I do updates one by one (ie one move or one delete at a time) it works when back to noedit mode. But with more updates I get application crash. (I'm using a fetchcontroller)
Could someone try this from a tableview not populated :
- create 3 rows
- hit edit mode and move 1st cell to 3rd position, still in edit mode delete the second cell.
- back to noedit mode it crash for me
Besides this I'm trying to make it work in grouped style and with several sections, where you can move cells to any section. Is someone knows an application doing this correctly ?
Thank you

Well after days trying different solutions it seems I finally get what I wanted.
In addition to Ryan Ferretti solution I had to put a flag to bypass tableview updates when commiting moved modifications on CoreData, to get it work with nsfetchedresultcontroller delegate.
It is describe on Apple documentation, see User-Driven Updates : http://developer.apple.com/library/ios/#documentation/CoreData/Reference/NSFetchedResultsControllerDelegate_Protocol/Reference/Reference.html
I now get a tableview grouped style and can move rows from any section to another one, sorted like I want.
So don't forget this flag. :-)

Related

Preload tableView cells and prevent reloading

I already found entries with that topic on this page and also a website that provides a tutorial for that problem. But nothing worked very well.
The tutorial sad I should double the height of my tableView so cells loaded earlier, but with a higher tableView I never reached the last cells.
My problem is, I use a tableView to display my apps mainpage. This mainPage shows every time a topic and if its necessary for that topic it shows for example a cell with a map, one with pictures and sometimes not. Problem now, if I trying to scroll to my view its always lagging because it loads a map or this pictures. And scrolling back again because the loaded cells already deleted. I used a tableView because of the possibility to switch celltypes(mapCell, pictureCell, textCell) on and off.
I understand this feature, because of memory issues but in my case its not that much and it would be better if all my cells be preloaded and stay in memory until I change the topic.
Is there a swifty way to told my tableView to have this behavior?
Thanks a lot and nice greetings
I would suggest a different approach. Set up your table view controller to install placeholder images in your cells, trigger an async download that you cache to disk, and then update the cell with it's downloaded content if it's still visible when the download is finished.
There are various third party frameworks that do all this housekeeping for you.
Declare a cell array.
Follow these steps whenever change in your topic.
Clear you array
Create and configure all cells add to your array.
Return these cells to datasource methods using row index. Don't use tableview dequeue method here.

NSFetchedResultsController saving data but UITableView not configuring cell

When returning from a ViewController where I add and save an NSManagedObject, the TableView inserts a blank cell where the new cell should be. If I back out from the tableview screen and go back, it reloads and configures everything properly.
So what I know from this is that the data is being properly saved to the store, I know the FRC delegate operations are all being called (.Insert, for instance), and I actually can see via breakpoints that my "configureCell" method is being called and is passing back a fully configured cell. The tableview is just putting in a blank one instead.
I can post code if you'd like, but I was just curious if this description rang any bells for anyone? I've been researching this problem off and on for weeks but haven't really found anything similar.
For troubleshooting purposes I:
took my custom UITableViewCell out of the mix and just had the tableview configure a generic cell... didn't help.
created a stripped-down version of the app flow in another project, including core data, FRC, custom tableview cell, etc... this actually DOESN'T display the same behavior. I've compared the two projects side by side and can't determine any meaningful difference (other than the data itself that's being displayed).
I've even gone so far as to insert a delay between the context.save() operation and dismissing the VC where I create the object, just to see if it's some sort of race condition between when the object is created and when the table configures the cell. Needless to say, that did nothing.
Is this a bug anyone else has encountered? Anyone seen this behavior before?
Thanks in advance, sorry for the wall but this is something that Google, various subreddits, and so far StackOverflow has not been able to help me with.
Well after rephrasing my question I found this from back in May.
New table view cell shows as a blank cell
No solution there, but I reached out to him via twitter and his suggestion worked. Switching my size class back to any/any seems to have solved the problem, which means this might be an autolayout bug. It needs more testing but I think I've done everything that would demonstrate the issue and I think it's resolved.

Restore custom table view cells when the app is restarted

I have a master/detail app for iPad, with a few sliders on a table view cell to control the XYZ position of an image. Every time I add another cell, another image will show on the screen that can be moved around.
When the app is restarted the table view cells that I added disappear. I already have it set up to record and save the slider values to NSUserDefaults, but I want the cells to stay on the view. How can I save the cells, so they aren't deleted when the app is reloaded? I would also like to save the sliders' positions when the cells reload.
You probably need to add persistence to your app.
Some ideas to get you started are in this StackOverflow post.
You'll want to save the data for each of the cells, and recreate the cells when your TableView reloads upon app launch.
You can update the sliders with the stored values as well.
Posting the code you're using to do this, along with any issues, may help the community help you resolve this.

WatchKit Table flickering when updated

I am currently working on a watchkit app and ran into a problem with a flickering table.
The situation is as follows: With the storyboard tool, I created a table containing two row types.
The concept is, that when the data for the table is being downloaded, there is only one row of the first type which will use the whole space to indicate, that data is being downloaded. When the data arrives the second row type is used to display the data.
The problem is, that the table is somehow flickering, while it is being updated with the data. I was able to fix this problem by removing the download indication message und using only the one row type for data.
My question is, if someone did run into a similar problem or if there is any better way/pattern to display this kind of information messages, which show the user whats going on when he is using the app.
The WatchKit Table will flicker when reloading when a visible cell is different size than the other cells. Make sure they are all the same height and width and you will not have a flicker.
The way I did it was to put a group above my table that took up the entire screen with a loading animation inside it. I then hide/show the groups as needed.

UITableView keep the scroll at the correct position while updating NSFetchedResultsController

I am developing an iOS application that mainly use a UITableView.
It retrieves pages of articles from a server. We have got >25000 articles; so I have implemented a pull-to-refresh and infinite scrolling to travel across the title collection.
The ones downloaded persist using core data; NSFetchedResultsController is used to automatically update the UITableView.
However, I have implemented the infinite scrolling to be in both direction; up and down. Since the user will be allow to scroll down the 25000 article titles, I have to remove the one that the user has already scrolled. If the user scrolls up, I have to re-insert title above the current one.
Doing so, I have got a moving window inside the article collection.
I display my articles by date group using the section and header.
The problem is that because the infinite scrolling goes in both direction, I often delete or add article at a higher position in the table.
Infact to achieve that, I have got to change the predicate associated to NSFetchedResultsController.
This result by scroll being messed up. I have made it jump back to the position where it was supposed to be ish. It is not nice because it is a jump (animation:NO), if I put the animation ON, it goes all around the place before going back to the right position. And the position is not exactly the one it should be.
I am not sure I well explained my problem. I think the problem might be in the way I am using the UITableView but I am not sure how I should use it to make this better.
Cheers
If you only store article titles in Core Data, I think it can handle 25.000 titles.
However I think that the problem you've got is with the pagination of the visible elements of the table
Here is a link that I used to handle something that you requested. You'll have to tweak a little bit to use Core Data and a remote source.
Please post some code if you can so we can have a look.

Resources