Select file| in the menu bar new| File ... command, select Property List, create a 1.plist file on the desktop
Core code:
#import <UIKit/UIKit.h> @interface viewcontroller:uiviewcontroller<uitableviewdatasource>{ Nsdictionary *list; Nsarray *a;} @end
#import "ViewController.h" @interface Viewcontroller () @end @implementation viewcontroller-(void) Viewdidload { NSString *path = [[NSBundle mainbundle]pathforresource:@ "1" oftype:@ "plist"]; Nsdictionary *dic = [[Nsdictionary Alloc]initwithcontentsoffile:path]; list = dic; Nsarray *array = [[List allkeys]sortedarrayusingselector: @selector (compare:)]; A = array; [Super Viewdidload]; Do any additional setup after loading the view, typically from a nib.} -(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{return [a Count];} -(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{nsstring *year = [a Objectat Index:section]; Nsarray *moviessection = [list objectforkey:year]; return [moviessection count];} -(uitableviewcell*) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{static NSSTR ing *cellidentifier = @ "Cell"; UITableViewCell *cell = [TableView dequeuereusableceLlwithidentifier:cellidentifier]; if (cell = = nil) {cell = [[UITableViewCell alloc]initwithstyle:uitableviewcellstyledefault Reuseidentifier:cellide Ntifier]; } nsstring *str =[a objectatindex:[indexpath section]]; Nsarray *moviesection = [list objectforkey:str]; Cell.textLabel.text = [moviesection objectatindex:[indexpath row]]; return cell;} -(nsstring*) TableView: (UITableView *) TableView titleforheaderinsection: (nsinteger) section{nsstring *st = [a Objectat Index:section]; Return St;} -(void) didreceivememorywarning {[Super didreceivememorywarning]; Dispose of any resources the can be recreated.} @end
iOS Development Learning # Table View # (5) Populate Plain style grouping table