ios - UITableView from plist loaded into NSArray of Dictionaries -


i have been reading bunch of how to's on topic, haven't been able figure out.

if have plist this:

<?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0"> <array>     <dict>         <key>color</key>         <string>brown</string>         <key>height</key>         <real>40</real>         <key>length</key>         <real>75</real>         <key>level</key>         <real>2</real>         <key>name</key>         <string>bear</string>         <key>note</key>         <string>ugly, strong</string>         <key>width</key>         <real>30</real>     </dict>     <dict>         <key>color</key>         <string>tan</string>         <key>height</key>         <real>20</real>         <key>length</key>         <real>30</real>         <key>level</key>         <real>4</real>         <key>name</key>         <string>dog</string>         <key>note</key>         <string>cute</string>         <key>width</key>         <real>8</real>     </dict>     <dict>         <key>color</key>         <string>chestnut</string>         <key>height</key>         <real>75</real>         <key>length</key>         <real>90</real>         <key>level</key>         <real>3</real>         <key>name</key>         <string>horse</string>         <key>note</key>         <string>fast</string>         <key>width</key>         <real>22</real>     </dict>     <dict>         <key>color</key>         <string>gray</string>         <key>height</key>         <real>20</real>         <key>length</key>         <real>85</real>         <key>level</key>         <real>2</real>         <key>name</key>         <string>shark</string>         <key>note</key>         <string>hungry!</string>         <key>width</key>         <real>35</real>     </dict> </array> </plist> 

i can load data , print whole list this:

nsstring *path = [[nsbundle mainbundle]pathforresource:@"testdata" oftype:@"plist"]; nsmutablearray *foodslist = [[nsmutablearray alloc] initwithcontentsoffile:path]; nslog(@"did load - foodslist = %@", foodslist); 

but when go load uitableview have list of names, can't working.

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:@"cell" forindexpath:indexpath];      cell.textlabel.text = [[testdata objectatindex:indexpath.row]objectforkey:@"name"];      return cell; } 

the nsmutablearray *keyvalues = testdata[key]; line fails going between dictionary , array types.

what doing wrong?

thanks,

dan

you not setting text anywhere inside cellforrowatindexpath:

set cell label text

cell.textlabel.text = @"hello world"; 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -