Loading new cells added from Parse data class - ios

I'm creating an app for clothing shop and I'm using parse cloud to upload and retrieve data from it. But when I add a new item to the data class, it loads at the bottom of the tableview.
How can I make the new items or the new cells load from the top of the table view like at the first cell?
I'm using PFQueryTableView from Parse instead of the original tableView.

If you are using PFQuery then you can trial & error using:
– orderByAscending:
OR
– orderByDescending: - right after you update the data source.
Also, you might want to check out This Discussion.
Let me know, if it works for you.

Related

Firebase and table view duplicating data swift

I use firebase database and table view. I put there an object. The code:
thingManager.addNewThing(thingName.text!)
let thingRef = self.thingsRef.childByAppendingPath(thingName.text!)
thingRef.setValue(thingManager.toAnyObject(thingName.text!)
All of the elements from database are displayed in table view. Table view is loaded everytime the application starts.
I load the table view by having an array from which table view takes info. Everytime the app is loaded, the array is filled with elements from database.
The problem is that the elements duplicates in table view when I add new object to the database. The data doesn't duplicate in the database itself, but it duplicates somewhere in that array. Tried multiple things and when I delete the last two lines
let thingRef = self.thingsRef.childByAppendingPath(thingName.text!)
thingRef.setValue(thingManager.toAnyObject(thingName.text!)
everything works fine, but the data is now not saved in the database. My question is: can these two lines cause the duplication? Thanks in advance
I had this same issue. I was loading the Firebase Data into a GLOBAL Array of structs. I was able to fix my issue by switching the Array to a LOCAL array in my tableView class. Let me know if this helps:)
your code is not very clear, but i think you need
dispatch_async(dispatch_get_main_queue(), {
self.YourTableView.reloadData()
})

UICollection View to display data from parse

I've been trying to get a standard UIcollectionView to display information pulled from Parse and it is not working at all. All I need is a simple way to implement a Collection view to show the name of the item with an image to display the item. The number of items in each section is equal to the PF query. count that was performed. But I need to figure out how to display the items and how to create a working collection view.
You can refer this tutorial for UICollectionView.
It has nothing to do with the Parse or PFQuery at the moment.

How to display data from Core Data database in custom TableView Cells?

I want to display data from a searchable Core Data database in custom TableView Cells, which consist of a small image, title label, and price label. How do I go about doing this?
Best regards.
There's actually quite a lot that goes into it. First you need to use a custom table view and some custom cells. Then in the custom cell code you can set the data for various labels and field. This is usually done by passing the cell an object, the cell reads the object and populates the data.
I used this sample code to get started in a similar project, the only difference being we parsed our data from xml instead of getting it from core data. This code will show you how to populate the cells, I think it reads it from a static plist but you should be able to modify it to suit your needs.
https://developer.apple.com/library/IOS/samplecode/TableViewUpdates/Introduction/Intro.html#//apple_ref/doc/uid/DTS40010139

Infinity Scroll and UITableView Data Reload

I'm implementing infinity scroll to load new data in my uitableview that is implemented like Contacts style in Apple embedded App.
My datasource is a IList and then i add new elements on it.
When load new datas to that list if i don't call
this.TableView.ReloadData()
my UITableView doesn't show the new elements added.
That method generates a ugly effect of white screen for a bit, to show next, succesfully, the data added. There are others ways to do that without that effect?
For example using ReloadRows...i can't use that method because i don't understand in which way pass an NSIndexPath[] for rows that aren't loaded yet
You can use the insertrowsatindexpath methods - see the apple documentation at http://developer.apple.com/library/ios/ipad/#documentation/userexperience/conceptual/tableview_iphone/ManageInsertDeleteRow/ManageInsertDeleteRow.html - especially the batch operation section

Moving cells from one table to another in iOS

I am trying to create an application with multiple table views that uses and implements Core Data. I would like the user to be able to select cells in one table and move them to another (like in Apple's mail application) using either a check accessory or a selectedCell method with an action sheet. I'm stuck because I don't know if you are actually moving the cell to another table or if you are adding a copy to the new table and deleting the original. Basically, I'm asking for a basic example of cell movement to give me a push in the right direction.
You won't be moving cells. The model for a table view is an array. Move things between the arrays and tell the tables that their model has changed.
id somePartOfMyModel = [self.arrayA objectAtIndex:someIndexPath.row];
[self.arrayA removeObject:somePartOfMyModel];
[self.arrayB addObject:somePartOfMyModel];
// the simplest, non-animated way to update the tables.
// I'd advise getting this working first, then later trying fancier UI to indicate changes
[self.tableViewA reloadData];
[self.tableViewB reloadData];
You would not be technically moving the cell to the other table. The way I would go about doing this would be to pass the NSManagedObjectContextID of the item between the tables, depending on how large your entities are and if the tables are in the same view controller.

Resources