data table in iOS - ios

I want to ask something about iOS .I get the values from xml file after that I parsed and I want to insert database (sqlite).How can I do this.How can I create dynamic tables and columns .Do you have such a structure in objective c .
similar datatable c#.

The Sqlite3 C API is accessible directly (you need to link the build product against libsqlite3 in the link with libraries build phase). You can either write elements to a pre-created sqlite database (if you already know the structure of the data), or store the elements in NSMutableArray/NSMutableDictionary until the XML parsing has ended (provided the XML data isn't too huge to fit sensibly into memory). Then create an appropriate database to store the data.
You can also use core data which is the apple recommended way (and which uses sqlite under the hood), with a nicer object oriented API.
The C API is described in detail here, and it links to specific examples for many different common sqlite operations. There are also objective C wrappers for sqlite like this one if you're uncomfortable with C.

Define an object class with all the relevant fields you find in the XML (title, date, description etc), then iterate through the parsed XML creating a new object for each row. Once the object has been populated, store it in a MutableArray and move onto the next.
You can then pass this structured array to your database, where you can again loop through it and extract the values. You might want to read up on FMDB as it has a lot of useful functions built in to aid this.

Well you can use SQLite with iOS. Better there is Core Data.

Related

Best design pattern to handle iOS Application State/Data

I am starting a new project (learning purposes) and I am trying to figure out what is the best software design pattern to use in the following scenario.
I have several data that need to be downloaded from multiple webservices and store somewhere in my app, to display it later. However each piece of data (e.g. list of teachers, students) will only be used in one or more specific view controllers (e.g. teachersViewController and studentsViewController).
I read that the Singleton pattern or use the AppDelegate to store a variable (an object like ApplicationData) is a bad practise, even more in this example which I want to restrict the data access.
So, which design pattern should I choose? I have read something about dependency injection, but I don't have any clue about it or if it even helps me in this question. If it helps, some examples with explanation would be nice.
You need some sort of database to store downloaded data. Good choices are Realm and Core Data. The right way to process data is:
Check if data is already in DB and show it if available.
Download or update data from server and parse it to objects.
Save objects to DB.
Show data taken from DB to user.
Download data as needed. When you open VC with students then download only students data and so on.
EDITED: If you need all the data on app open then load it and put in a DB before first screen opens. Then just use DB to show data to user.

how to store things in core data and sync with backendless

I need help with the logic of my app. I am new at coding.
Currently, I am coding a expense tracker kind of app. I can add a picture and type in the details in the fields provided.
The current flow is that these data are stored straight away in Backendless. however, when i load my uitableview, it is being populated by fetching the data from backendless immediately, which makes going between the different tabs slow as it has to load from backendless each time i change the view.
While trying to solve that, I would think that storing data in core data would help me populate my table quicker, however, I am not sure of how my core data and backendless should link up. I only have swift knowledge.
Can anyone advise me on how the flow should be like and whether I can do this with backendless api or if I would require other languages in order to achieve this?
You don't require other languages, but the backendless API (at the time of writing) has no support for core data.
Backendless will only deserialise incoming data to plain custom model classes, which you can take a update into core data, but you need to write that logic.
There are a number of mapping libraries which take one object and map it into core data, looking for unique identifiers to prevent duplication in the data store. I can't say that any of them are ideal because you usually want to use a custom class with backendless and a different custom class with core data.
If you don't register a custom class with backendless then it will deserialise to plain arrays & dictionaries and this will likely be easiest to use with mapping libraries. You might need to do a bit of manipulation to get the data into a mappable format...

using a array list in ios to create a translation app

I am taking development courses for ios and I was wondering if I wanted to create a translation app would i use a array list to do so? As example code is:-
var dictionary = [“talofa”: “hello’, “faafetai”: “thank you”]
print(dictionary[“talofa”])
it shows up in the logs as “hello” but there has to be an easier way to do translations otherwise I would be fitting a whole language in a array list?
I also read online that people have been using third party services like google to make a translation app but my language is not on google (Hawaiian) what do I do?
First of all, what you are using in your example, in swift/objc it is called a dictionary.
Secondly, for such a huge amount of data, I recommend you use some sort of persistent storage. You can use plain text to store the dictionary (like creating a .plist file), but being iOS I would recommend setting up coredata.
CoreData will allow you to store the information on the device, and access it through a data Model.
Here you can find an example on storing in a file.
Here you can find an example on storing in CoreData.
I personally recommend using coredata for such a large quantity of data. Plist files are more suitable for storing low information quantities (like saving some credentials, some settings, etc).
You need to use DB for this. You can update it from your server when user will have connection, so you don't need to re-submit your app when you will update your vocabulary.
You can use CoreData as #Alex Bartiş told you or you can try another one which becomes popular: Realm

(Swift iOS) Storing Article Content (image/paragraphs) locally

I'm planning out a sort of reference book application. For each topic there will be a page with an image and text stored. I don't want to create new views in xcode for each page since there are 100+ topics, I'd rather find the easiest way to store the items in a database and then call the content to display on a view template when the user selects the topic from a list. After searching around I see that this is potentially done with Core Data or SQLite, and maybe even json, but I have not encountered a clear answer.
What's the best way to handle this sort of data?
You should create a database in Core Data and where you'd like to store images, use the response from this tutorial (conversion to Swift is left as an exercise for the reader) and store the fileName as a string.
Don't use json to store 100+ items, it will be very slow. SQL is quite fast, even though it's a mobile device.

convert raw data into ios application readable format

Am new to ios application development, but not to application development. Previously i created an android application, a part of it contains an array of elements(say list heading) and its corresponding description (in another array) i didn't have any trouble in retrieving those array elements and using them.
Requirements:
my project is not very complex to use SQLite datastores or Core Data.
i could have the data inside the application variable itself and use them as they are only used at the particular page.
i require a very simple solution to convert my existing data as said arrays.
Problem:
Now i would like to perform the same for ios application too. so i dont want to create the same array like structures redundantly.
Assumptions:
Am assuming tat i could write a script to generate the arrays into an XML File and parse them and use them in my application.
So i need some suggestions and directions on my assumptions.

Resources