Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm developing app that help people overview results of their training. In different disciplines different calculations. And I need to store discipline in object related to training.
I have to use this values in code to programmaticaly set fields of another objects, calculate results depend on it, and later to compare with it.
For example I have model Discipline and three records with names
Speed on 400 m
Speed on 1 km
Speed on 4 km
So it's some kind of constants and I'm just wondering what is the best practice to declare and access them?
Or may be is there any way to declare predefined objects?
Anytime you have "predefined" objects you should probably look into using an enum, though I don't really know why you would want to do that with an AR model. The whole idea behind an AR model is that it's an interactive object backed by a database that can have its attributes manipulated via CRUD operations.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 months ago.
Improve this question
I am brand new to ios development and am looking for some advice on the best way to structure my user data and access it throughout my app.
Data is retrieved via HTTPS requests that query a database for the desired information. There are separate calls for the different tables containing information of interest. The returned data is formatted as nested dictionaries where the outermost key is the column and the subsequent dictionary is key-value pairs of the index and the table value. Example:
{"column1":{"0":"value1-1", "1":"value1-2", "2":"value1-3"},"column2":{"0":"value2-1", "1":"value2-2", "2":"value2-3"}...}
My primary requirement is that I will need to be able to filter this data by the innermost values (some will be dates, some will be numbers, etc). I would like to have the data in a format that will make this simple to do and will not cause delays as there is no limit on the number of possible rows.
I have looked into reconstructing a user-specific SQLite database with the information and querying that throughout the app as necessary. I have also explored dataframes as this app was originally developed in python - don't ask - and relied on pandas dataframes.
I know this decision will impact me heavily and am trying to do my best to make an informed decision. I appreciate any feedback and am happy to give more useful context that might be missing.
TIA
You can use SQLite database for persistent storage. This is ideal for your main requirement of filtering the data. You should also create a structure or a class modelled on your data to store and use during runtime. You can refer this for deciding between a class or structure.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
For testing, I needed to generate a list of data values randomly and put them into the models for further use. But I found out that there is no library, which could produce such functionality.
The elegant solution I expected to find had to combine such simple things as:
the variety of data;
the variety of methods to reach this data;
the possibility to change the default data set to the custom one.
Since I hadn't found the accurate solution, I decided to create my own library (ref. https://github.com/codeitua/ios-data-factory).
There were implemented all necessary methods for data generation (including random names, cities, addresses, dates etc) and data retrieve. And moreover, it has "swifty" interface, which provides comfortable use in every project.
I hope, it will be helpful for everyone, who faced the same problem as me!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have an array in Swift that holds the number of shifts you've worked for the work week.
I would like to retrieve the first element from this collection that matches on a particular condition (in this case date worked).
Later, however, I may also want to find other things such as your highest earning shift. I might even want to select all items that match a particular clause instead of just one.
Are predicates involved here in doing something like this generically? Would anyone be able to point me in the right direction or share some code examples that could help me achieve this so I don't have to write multiple functions for a specific purpose on an array?
Thanks so much for your help!
The easy answer is simply to use indexOfObjectPassingTest and the correct predicate. This is effective when you want to do a small number of unique searches on a small array, where it's next to useless to abstract each type of search in its own function.
However:
if you have the same search made in multiple places in your code, consider abstracting the code into functions and even its own class
if you have a very large array and if the predicates can be very complex, consider CoreData or another database solution. You'll be better off in the long run.
if you need large result sets, also consider CoreData/databases
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I want to create a searchable database in Xcode - for example, of different trees. The database would consist of the tree name, two images, price, and a short description. What is the best and most efficient way of creating such a database?
I am aware of: Core Data, SQLite3, and Parse. I am leaning towards SQLite3 but have not found a good place to learn how to implement this. Any suggestions?
Seeing as you are new to Objective-C and I doubt this will evolve into something need direct SQL I would suggest using CoreData. Although it is not technically a data base it is an object graph, it is built for exactly what you are wanting to do. Apple was even nice enough to build wrappers for everything you want to do.
CoreData to store your tree name, two images, price, and a short description.
NSFetchedResultsController for grabbing it.
UISearchBarController for letting the user search.
You would want to use Parse if you wanted to save your data to a server. If your doing everything locally I wouldn't worry about Parse. CoreData is what you want.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How to validate incoming data using stored procedures in real time? can some one explain this ?
You can, but I think this is a bad idea. Business logic does not belong in a database. It belongs in service code (middle tier of an application). The role of a database is to retrieve and save data, not validate it. At least not in the sense of applying business rules.
Now, you can do 'validation' in the database in the sense of check constraints and foreign key validation, but this would not be done in stored procedures. This is native support built into most modern database systems.
So, in my opinion, forget about doing data validation in a stored procedure. As I said, validation doesn't belong there, and, it's going to be much slower than putting that logic in a middle tier using C++, C# etc.