Saving parseable string into core data - ios

I 'm developing an uitableview based application which sections and rows numbers for different selecions are determined by the data from core data. Now i need a structure for keeping user's choice.
To be clear, its an password saving app and users can save their informations according to pre installed templates. As seen in the images below, different key value pairs, for wireless router and instant messenger selections, are shown in the table view. I keep rows information for different types in core data so that rows can be loaded dynamically according to values from core data...
The application is for one user. User can change the values of a any row including the row in title header, "wireless router" value for example... After a user make some changes in the rows' value and click "Save" bar button at top right, a third tab will be added to below and will display this new data modified by the user.
My question is how should i keep the new data modified by user?
My core data structure is;
A solution comes in my mind is to keep values as a parseable string in a table, which is "SavedData" in image above.
What approach can be more suitable to solve what i need. Is saving key value pairs into one table as parseable string sth proper and efficient? or is there a better way.

NSUserDefaults is a versatile solution. It accepts NSArray, NSData, NSDictionary, NSNumber, NSString. There are many different ways you could model this. If you expect the app to have multiple users you could store Dictionaries of usernames, passwords, url. If the use case is only one single user than something like this should work fine. Top line is to save and bottom line is to read from anywhere in the app.
[[NSUserDefaults standardUserDefaults] setObject:usernameTextField.text forKey:#"flickerUsername"];
NSString flickerUsername = [[NSUserDefaults standardUserDefaults] object ForKey:#"flickerUsername"];

Related

How to move a checkbox with a row in google sheets with data sorted using SORT?

I am currently a college student who was trying to make a dynamic google sheet where my data is organized. The premise is as follows:
I input raw data into one spread sheet titled "Raw Data"
That data from raw data is automatically sorted by date using the SORT function to keep it dynamically updated.
If an item in the organized data is checked, then the row turns gray and updates into a corresponding chart.
My problem is that as I add or edit data, the checkbox is stuck to the row. In the first picture, you see the normal data as is.
organized spreadsheet data using a SORT function
However, lets say I add a due date for an assignment on 1/31/23. Then this happens.
Spreadsheet data following SORT function modified to show problem
So overall, my question is how can I lock a checkbox to a specific row so if the row is moved, the checkbox moves with it? If it is needed, I have a public link to the spreadsheet if it helps understand the problem:
Public Spreadsheet 1/31 for Clarification
I currently tried several data validation rules but most of them simply locked the cell from being edited if it was checked.
I also tried modifying the RAW data and adding a checkbox there before the sort function refreshes but that negates the point of the sheet at all then.
I was not sure how else to go about it trying to lock it into that place. Also, I was not sure how to upload as a MARKDOWN text table so I figured an image would suffice for the problem.

List or auto-complete existing string values, for new plaintext cell

I have a plaintext column in my Google spreadsheet, several rows (cells) of which have already been filled with a limited number of strings, let's say for simplicity "January", "February", "March", etc.
I would like to format the column such that, when entering text in new (empty) cells, rather than having to type the text from scratch, I instead get to choose from a drop-down list populated with the strings that already exist in other cells of that column (all 12 months, in the example above).
Or, alternatively, to have an auto-complete that would suggest, say, "March" and "May", once I start typing "M". Strangely, I haven't seen this basic feature at work in GSheets for a while, even though the EnableAutocomplete option is checked in the menu.
Among the two options, I would prefer the one with the drop-down list over the autocomplete one, but ultimately either would be of massive help. The idea is, once the number of unique strings becomes high (but there is also a lot of repetition), to reduce the chance of making a typo when entering new values just because they happen to differ by one letter from a string that already exists elsewhere.
Is there a way to do this just via the GUI/addons? I know this is possible to do in Excel for the header row (screenshot below), but I don't know of a way to do that also in GSheets, and in either case, what I need is to have this sort of selection list at the cell- rather than at the header-row level.
what you are looking for is called Data Validation:
and you can select various options for criteria

How to update individual array element in firebase with iOS Swift?

Here i'm using firestore query to update, insert data. How to upadate dictionary of array value to firebase database.
here is my firestore data structure:
Right now able to get data of slot1 -> 0th position value in a model class.
how can i update value of slot1 0th position of isbooked boolean value alone, without affecting remaining values and other slot.
You can't without reading the entire document, modifying the array data in memory, then updating the entire array field back out do the document. The smallest unit of change in a Firestore array field is an entire field. You can't make smaller changes to individual elements of a field, except those defined by arrayUnion and arrayRemove (which are not compatible with what you're trying to do here).
You can do that by getting the exact id of your structure ..
Database.database().reference().child("SlotName").child(yourAry.key).child(yourAry.key).child("isbooked").setValue(true/false)
Manage your database structure accordingly, its just an example and as user Doug suggested have a look on docs too ..

Use Core Data With UITableView With Sections That Have A Different Number Of Cells

So I have a TableView contains sections that can possibly hold a different amount of cells depending on the user input for rows for detail. I trying to learn more about saving and want make a simple app that allows the user to save recipe ingredients. For example I can have 5 different sections containing 5 different types of food like -> banana: amount-2 Calories-10 Details-Slice, Apple amount-3 Calories-20 Details-Mash <-. The User would then click done and his or her recipe name will be saved and displayed on a cell in another table view. Once the user clicks on it he/she can see what he/she put and can edit it if he/she desires. I was told that Core Data would be best for this type of saving.
How could I save all the info in a organized way. I know how to save individual cells using Core Data but what is hard about this is each section can contain a unique number of cells and then this data is all saved into one data entry. It's like an array inside of an array inside of an array. I also have a feeling that I have to use dictionaries. I can't seem to structure all of this data. Can anyone help or have any tips on how I should attack this? I'm using Swift by the way.
Picture of what one section of the TableView might look like:
There's several ways you can tackle this situation. The first solution that came to mind was storing a unique array for each section that you want to display. E.g. a fruit array, vegetable array, etc. If you did this, when you fetch from Core Data you would store the items in the appropriate arrays and do something similar to the following within your numberOfRowsForSection:
switch (section) {
case 0:
return fruit.count()
case 1:
return vegetable.count()
default:
return 0
}
That switch statement will be called according to whichever section you are in at the time. If you went with a different route like a dictionary, instead of returning the count of the different array, you could return typeDict.objectForKey("fruit") instead.

Storing the (array data)session in core data iOS

In my application I have seven category button on firstController which open secondController(tableView) having arrays of question. This question are in tableView which having Yes, NO buttons option for check/uncheck marks. Selecting Yes-No option will change the colour of tableView row. After answering the question the user can generate audit report(1st session). This report is usually PDF file. I am printing all the checked question on the PDF page and saving.
I have used NSUserDefault for saving all the array of checked question and NSDocumentDirectory for saving PDF file. In the current scenario, the User has to reset all the thing before he want to work for the second audit report(second session).
Now customer want the flexibility to save 1st incomplete audit report in database and would like to go for completing second audit report. Hence he can complete 1st audit report later and so on...
I have never used Core Data before, hence will the core data help me in above scenario. How can I apply logic here from scratch. Can some one give me the better idea. thanks in advance.
Edited with Explanation
I have 400 question array list taken in tableView with check/uncheck button. But for audit, user can checked question by his wish. say 100 question he checked so that he would save 100 question and print as a PDF pages.
User would like to have chance to save all incomplete session of checked-unchecked question to access it later to convert this as a PDF file.
Which method will be better?
If you just have an array or booleans or identifiers for your selected rows, don't use Core Data. Instead, just save the array to disk using writeToFile:atomically: and read it back in when required using initWithContentsOfFile:. You only want to consider Core Data if you want to store more information.
You can also have an array of dictionaries. Store the whole thing, not just the edited values (to make indexing easy). Colours are interesting. You could encode them into strings as comma separated rgb values or use an archived to convert them into data. You can't directly put the colours into a plist. You could put the colours into core data as transformable.

Resources