I wish to display table section with date as the section title and name of book in the row. I'm all lost at how to use a NSDictionary to load data into section and rows. Therefore my codes are all screwed up :( Can anyone offer some help, with some sample codes as a guide? My NSMutableArray is as followed:
(
{
BIBNo = 187882;
date = "14/08/2012";
itemSequence = 000010;
name = "Increasing confidence / Philippa Davies.";
noOfRenewal = 0;
number = 000187907;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 291054;
date = "14/08/2012";
itemSequence = 000010;
name = "iPhone application development for IOS 4 / Duncan Campbell.";
noOfRenewal = 2;
number = 000291054;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 244441;
date = "15/08/2012";
itemSequence = 000010;
name = "Coach : lessons on the game of life / Michael Lewis.";
noOfRenewal = 1;
number = 000244441;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 290408;
date = "15/08/2012";
itemSequence = 000010;
name = "Sams teach yourself iPhone application development in 24 hours / John Ray.";
noOfRenewal = 3;
number = 000290408;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 161816;
date = "16/08/2012";
itemSequence = 000010;
name = "Malaysian Q & As / compiled by Survey & Interview Department ; illustrations by Exodus.";
noOfRenewal = 1;
number = 000161817;
status = "Normal Loan";
time = "24:00";
type = Loans;
},
{
BIBNo = 187883;
date = "16/08/2012";
itemSequence = 000010;
name = "Positive thinking / Susan Quilliam.";
noOfRenewal = 3;
number = 000187899;
status = "Normal Loan";
time = "24:00";
type = Loans;
}
)
How do i actually re-add the objects into NSDictionary so that objects with the same date would be stored together to be displayed as rows in the section? Please offer me some advice thanks! T_T
In short, you can't re-add objects to an NSDictionary. That is because NSDictionary is immutable. Once it has been created, it's contents can not be modified. What you want is an NSMutableDictionary.
You can then use the setObject: forKey: method.
https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsmutabledictionary_Class/Reference/Reference.html
To process your data you would need to do something like
Then to get the section title
Then to get a row in a section
As A-Live said you are going to have to sort your Array in to a Mutable Dictionary of Arrays
The following code should work, but it's untested
In TableView Controller .h
In MyController.m
}