Display an NSSet/NSMutableSet of different objects in a UITableView - ios

i'm new to SOF and i hope this is a good question to begin with :)
i'm stuck with the following issue:
I need to display a NSMutableSet with the content of 2 different NSArrays containing 2 different object types in the same TableView and also in the same section.
I've tried with an NSMutableDictionary but couldn't figure out how to display the NSArrays stored into the dictionary, the first one and then the second within a sole section.
Thanks in advance.
PS: what i'm trying to do is to display entities like Meals, Foods and Drinks for a specific day in a tableView with grouped cell for each mealtime. So the grouped e.g. for a lunch shows 3 entities: meals, foods and drinks.
I'm getting NSSets of Meals, Foods, Drinks using a relationship to the Day Object. I tried to put them in an 2 dimensional array but failed on loading cells(it shows only the last object).

You can ask the Object in the NSArray for its type with isa.
According to the answer you can prepare the cell in prepareForRowAtIndexpath

Related

In Google Sheets return all cells that contain string

I've seen a lot of similar questions where users want to returns all rows that contain a specific value, but I'd like to only return the cells that contain the value.
Basically, I have one sheet that has a bunch of categories in different cells, on the second sheet I'd like to return every category that contains a "_". I tried =QUERY(cat!A:Z,"select * where B contains '_'"), but that returns the whole row, I just want every cell individually.
Thanks for any suggestions!
Try this one:
=TRANSPOSE(SPLIT(
ARRAYFORMULA(CONCATENATE(IF(REGEXMATCH(Sheet1!A:Z,"_"),Sheet1!A:Z&"~","")))
,"~"))
You may use some rare symbol, like ~ to join and split the result, so it shows in one single line.
Data sample
Result

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.

Set each sections of tableview with different query data from Parse

What I am looking to do is have 2 sections in my tableview which I can do by specifying 2. From there I am stuck. I am performing 2 queries from Parse to gather the details I need. 1 query gather extremely urgent data and the second is data about less important events. Each query has its own array so I am thinking it should be pretty easy to accomplish.
How do I set the first section to the urgent array (self.urgent) and the second to the less important events array (self.event)? I know how to configure cells for a single section with an array but have never had to configure 2 section with different results.
Thank you in advance.

iOS Dictionary, add every nth value of one array to each key of dictionary

This is my first SO question, forgive me if its a stupid one but I's stumped..
I have 2 arrays, one of which contains only numbers (0 - 10, for example), the other of which contains a larger number of strings (lets say, 50 for this example).
Is it possible to create a dictionary using the keys from the (smaller, numbers) first array and values from the (larger, strings) second array?
part 2 (mostly independent of the first)
Ultimately, I'd like to use this dictionary for UITableView sections but I am also wondering if this is the appropriate or most efficient way to populate sections in a UITableView.
Thanks in advance
Question 1:
A dictionary stores key-value pairs, and the keys have to be unique. So if your 1st array stores (your example) 11 NSNumber objects representing the numbers 0 to 10, you have 11 different keys, and you can only associate 11 strings from the other array with these keys.
Question 2:
A sectionized table view has 2 indices, the section number, and the row number within a section. Together they are represented as an NSIndexPath object. So a natural choice of a data structure holding the table views data is an array storing the sections, where each entry is an array storing the rows of that section.

UITableview Grouping

I have a sorted array of strings. I want to group them using tableview section according to first letter similar to iPhone contact.
I am new to iOS can any one help me to do this, The array is retrieving from server.
and also there is a search option for table view
If I understood your question correctly, you want to group and index the items alphabetically?
There is a system class to do that, called UILocalizedIndexedCollation.
Here is a nice tutorial for it:
http://benedictcohen.co.uk/blog/archives/230
Please check this given below link
http://iamthewalr.us/blog/2009/12/uisearchdisplaycontroller-and-uilocalizedindexedcollation/

Resources