Storing the (array data)session in core data iOS - 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.

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.

Creating Dynamic Sheet Cell Reference List for pulling numbers to SUM

I've been working on building a data analysis sheet, which is quite verbose at the moment and a bit more complicated than it should be as I've been trying to figure this out. Please note, I work doing student data in a school.
Basically, I have two sets of input data:
Data imported from a CSV file that includes test data and codes for Common Core Standards and the questions tied to those standards as a whole class summary
Data imported from a CSV file that includes individual scores by question
I am looking to construct 2 views:
A view that collates and displays data of individual standards per student that includes a dropdown to change the standard allowing a teacher to see class performance by standard in a broad view. The drop-down is populated dynamically from the input data (so staff could eventually dump data and go directly to reports)
A view that collates and displays data of individual students broken down by performance on each standard allowing a teachers to see the broader spectrum for each student. The student drop-down is populated from Source list 2.
I have been able to build the first view, but am struggling with the second. I've been able to separate the question codes and develop strings of cell references to the scoring data, including a dynamic reference to the row the selected student's score data appears on in the second source set from above.
I tried to pass through an indirect() formula into a sum() so as to process for a mean evaluation, and have encountered errors. I think SUM() doesn't process comma-separated cell reference lists from Indirect() [or in general] or there is something that I am missing to help parse it. Here is the formula I have tried:
=Sum(vlookup(D7,CCCodeManip!$A:$C,3,false))
CCCodeManip!C:C includes the created text (based on the dynamic standards and question codes, etc), here's an example of what would be found there:
'M-ADI'!M17, 'M-ADI'!N17, 'M-ADI'!O17, 'M-ADI'!P17, 'M-ADI'!Q17, 'M-ADI'!R17, 'M-ADI'!J17
I need these to be dynamic so that teachers can input different sets of standards, question, and student data and the sheet automatically collates and reports it in uniform ways (with an upward bound of 20 standards as I currently have it built)
Here is a link to the sheet I built, with names and ID anonymized. There's a CRAP TON of sub-tabs, and that's really just being able to split apart and re-combine data neatly without things error-ing out due to data overlapping, aside from a few different attempts and different approaches to parse the cell reference strings.
The first two tabs are the current status of the data views. I plan to hide a bunch of the functional stuff that is there to help pull data accurately.
The 3rd and 4th tab are the source data sets. 5th is a modified version of source data that allows me to reference things better, and I've tried to arrange the sheets most relevant towards the front of the set.
https://docs.google.com/spreadsheets/d/1fR_2n60lenxkvjZSzp2VDGyTUO6l-3wzwaV4P-IQ_5Y/edit?usp=sharing
Some have a different approach? I am aware that I might be as far as I cn go with this and perhaps should consider scripts - my coding experience is a bit out of date and my strength is more with the formulas, but I can dig into things with some direction, if anyone can help.
Ok so I noticed something.
It seems the failure is in the indirect reference:
=indirect(CCCodeManip!C3)
The string I am trying to parse via indirect is going to be generated into something like this, dynamic from reference to other data:
'M-ADI'!M17, 'M-ADI'!N17, 'M-ADI'!O17, 'M-ADI'!P17, 'M-ADI'!Q17, 'M-ADI'!R17, 'M-ADI'!J17
The indirect returns the error that the above string is not a cell reference with the #REF code.
Can someone give me a clue as to what is causing this? I am going to dig into the docs on Indirect() from google and will post anything that I find.
Perhaps it is that indirect() can't handle lists, but only specific references and arrays, which may require me a to build a sheet to do the SUM formula on for each question set (?)
So I think I figured it out, but i Ended up parsing the data differently, basically doing the sum based on individual cell references and a separate sum formula, bypassing the need to do it all at once, it jsut makes my sheets a lot dirtier! I am eventually going to see if code could do it better if I need to, but this is closed for now.
Basically, I did individual cell references to recall scores in a row, then used a separate SUM formula, and created references / structures to be able to pull those sum() results. Achieves the same end, but with extra crap on the sheet.

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.

Saving parseable string into core data

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"];

Automatically updating Data Validation lists based on user input

I have a very large data set (about 16k rows). I have 10 higher level blocks and within each block I have 4 categories (10 rows for each) which use Data Validation lists to show items available in each category. The lists should automatically update based on user input. What I need your help with is that I want to use the same data set for each block and preferably a least calculation/size intensive approach. I have put together a sample file that outlines the issue with examples.
Sample File
Thank you for your help in advance.
Okay, I've found something, but it can be quite time consuming to do.
Select each range of cells. For instance, for the first one, select B3:B18 and right click on the selection. Find 'Name a Range..." and give it the name "_FIN_CNY". Repeat for all the other ranges, changing the name where necessary.
Select the first range of cells to get the data validation, and click on "Data validation", pick the option "Allow: List" (you already have it) and then in the source, put the formula:
=INDIRECT($G$4&"_CNY")
$G$4 is where the user will input. This changes as you change blocks.
_CNY is the category. Change it to _CNY2 for the second category.
Click "OK" and this should be it. Repeat for the other categories.
I have put an updated file on dropbox where you can see I already did it for the data of _FIN for categories CNY, CNY2 and INT and did the one for _GER as well. You'll notice the category of INT for _GER doesn't work, that's because the Named Range _GER_INT doesn't exist yet.

Resources