Proximity in a Table View? - iphone

I'm programming an application that lists a number of locations. I have the coordinates stored in a .plist, which I am using as a data source. I have trouble figuring out how to conceptually approach problems, so some help would help :)
I would like to Have the name of the location sit on the left while on the right of the table view, you can see how far away from the location you are (in miles / kilometers). Is there a convenient way to push this information to the table and sort the list?

You will have to port your plist data into a datasource NSArray for the UITable. You can use sorting functions of NSArray to sort your data at anytime and do refresh on the table. B/c you want non-standard data in the table cell you will have to design your own custom UITableCellView. You can find lot of examples on Stackoverflow on how to create custom cells and do sorting.

Related

auto create stackView from array count

Please tell me if I chose the right approach or are there other options?
I receive an array of objects from the server.
According to the task I have to place each object of the array in the table cell
How many objects will come I don’t know, I just mean that they all have the same structure and that they should be placed automatically.
I chose the path - stack view
Is there any easy way to automatically generate their number?
And whether I think correctly...
I need to create 1n total stack in the cell and transfer new stack to inside
there is response from server
https://jsoneditoronline.org/?id=9ebed4100d4d4db49aab728a16ac693d
each array must be a cell
inside each array - the array is a data set that should be automatically insert ....
maybe in the stack?
Use UITableView. It will be better choise
upd:
Use complex UITableView with sections.
Also some like this can help you: https://medium.com/#stasost/ios-how-to-build-a-table-view-with-multiple-cell-types-2df91a206429

real time update plist populate UITableView

Im trying to create an application that will show in a table 3 floors and in the detailTextLabel show how many computers are available in those floors. For now I dont have the realtime data but I want to just keep some fake fixed data for now and be able to plug in the real data later.
I thought I would create an array, FloorList and FloorListAvailable. Floor list would contain "First Floor" "Second Floor" "Third Floor" and FloorListAvailable would show a number of how many computers are available.
Im currently unsure on how to go about this, it sounds easy enough to do but I cant wrap my head around it. I thought about using NSDictionary. I have used the .plist but can that be changed to by dynamic when I get the real time data?
One possible approach:
generate the realtime data by a script (e.g.); JSON would be a good format
let your app download the data files with a suitable frequency
parse the JSON (see: NSJSONSerialization into own objects; e.g. arrays
use these arrays as the data sources for your table views
whenever you get new data, send reloadData to your table views

Sorting cells in UITableView into sections, after TableView has been loaded

Right, so my UITableView loads and puts all the cells in Alphabetical order. Information is then downloaded from a server and calculations are done, with the TableView being reloaded once everything is complete. Currently this is quite a simple procedure as once the information is downloaded from the server, the cells don't even move, they are left in their alphabetical order. Nothing really happens other than half of the information is filled in and small changes are made depending on the calculations. I was wondering if there was an easy way of putting the cells into sections depending on the calculations done after the download is complete? I did have an idea of creating 4 arrays (there will only be 4 sections ever) and once isLoading is set to no, changing the data source of the TableView to have sections, however, that sounds a bit... iffy. I know this is a theoretical question as opposed to a coding problem, but before I go and mess up my code, in what is sure to be a stupidly inefficient way of doing things, is there an easy way of "assigning" UITableViewCells to sections?
My main issue with my way of doing it is that should the user delete a cell, deleting the appropriate entry in Core Data will be a little tricky and prone to errors. This lead me on to another idea. What if I added an extra attribute to my Core Data entity. That attribute would be assigned and then saved once the calculations were done. The problem with this is that no existing databases would work. There has to be a neat way of achieving this.
Thanks for the help. If you need me to post any code just say so and I will.
You should be fine if you implement the data source methods related to sections.
For example:
numberOfSectionsInTableView
sectionIndexTitlesForTableView.
Any time the table data is reloaded (e.g., [self.tableView reloadData]), these methods will be called and the data will be placed into their sections.
Keep in mind that the cells are just the visual representation of your model, which in this case is your fetched data. The cells are not assigned to sections; they are simply created however you specify for your model (via the table view data source and delegate methods).
Regarding deletion of entries while using Core Data, I suggest taking a look at NSFetchedResultsController. The latter will monitor any changes to your table's data and message its delegate, your table view controller, when updates are made.
For example, a deletion would start with a call to the table view delegate like normal (i.e., via tableView:didEndEditingRowAtIndexPath). Within the latter, you would then delete the entry from core data (e.g., [self.myDatabase.managedObjectContext deleteObject:entity]). Assuming you initiated the NSFetchedResultsController w/ the same managed object context, the deletion would be automatically reflected back to your user.
If you're using a remote DB, however, you'll also have to perform a save (however you've implemented that) to ensure the DB is updated too.
Note also that if you use an NSFetchedResultsController, you don't need to implement the section data source methods since NSFetchedResultsController can handle that for you. Just define the key-path in your data model that will return the section name when initializing the NSFetchedResultsController.

How to store tree base data into Data base?

I am developing an application of iphone which is navigation based, and i am showing data on first View Items then on second View Sub Items and so on. So my question is that what will good approach to save this on Data base (sqlite).
Keep this simple.
Each object/View has it's own ID and at least one parent ID.
This will ensure your data can represent trees of any depth and any complexity.
i am not an expert in this field but you can do it like this ... now that you said all you data can be represented something like tree...
Find all the objects that will be leaf of your tree make those objects as a table in DB, (please keep in mind that you make table only for objects that have different structure not because they have different values)
Repeat above step for one level above until you reach top
Eventually you will find that you just got your DB.
To be more precise you need to study DBMS

iOS Human Interface Guidance for Changing Table Sort Column

First post. I'm still reading the iOS Human Interface Guidelines and haven't come across this scenario, yet. When displaying multiple columns in a table, what is the appropriate indicator to the user that they can change the column used for sorting?
Well, the UITableView is a one-column table. So, you can usually not change the sorting. I'd recommend reading the Table View Programming Guide. It says right at the beginning:
A table view has only one column and allows vertical scrolling only. It consists of rows in sections. [...]
I have the same challenge. I'm showing a single list of customers, each having a unique number and a descriptive name. I've added a segmented control to the middle of my toolbar that allows the user to sort by name or number.