• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Was gibt es Schöneres als den Mai draußen in der Natur mit allen Sinnen zu genießen? Lasst uns teilhaben an Euren Erlebnissen und macht mit beim Thema des Monats Da blüht uns was! ---> Klick

TableView aus plist

DanHard

Roter Delicious
Registriert
05.08.11
Beiträge
94
Hallo zusammen

Ich bin ziemlich neu in der Programmierung fürs iPhone.
Gerne würde ich mir ein TableView machen mit den Daten aus einer Plist, die ich dann später immer aktuell aus dem Internet laden kann.
Kann ich eine TableView machen die Aussieht wie eine Tabelle, alsk mit dem Club und Rang, Tore, Punkte... usw...

Wie würdet ihr das angehen?
Danke für eure Hilfe.

Gruss DanHard
 

DanHard

Roter Delicious
Registriert
05.08.11
Beiträge
94
Die plist sieht momentan so aus:

Code:
[COLOR=#b717a2]<?xml version=[COLOR=#ca2922]"1.0"[/COLOR] encoding=[COLOR=#ca2922]"UTF-8"[/COLOR]?>[/COLOR]
[COLOR=#450efe][COLOR=#b717a2]<!DOCTYPE plist PUBLIC [/COLOR][COLOR=#ca2922]"-//Apple//DTD PLIST 1.0//EN"[/COLOR][COLOR=#ca2922]"[URL="http://www.apple.com/DTDs/PropertyList-1.0.dtd"][COLOR=#450efe]http://www.apple.com/DTDs/PropertyList-1.0.dtd[/COLOR][/URL]"[/COLOR][COLOR=#b717a2]>[/COLOR][/COLOR]
[COLOR=#b717a2]<plist [COLOR=#927f36]version[/COLOR]=[COLOR=#ca2922]"1.0"[/COLOR]>[/COLOR]
[COLOR=#b717a2]<dict>[/COLOR]
    [COLOR=#b717a2]<key>[/COLOR]tabelleNLA[COLOR=#b717a2]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]    [/COLOR]<array>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]        [/COLOR]<dict>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]rang[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]1[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]bgoal[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]2[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]sgoals[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]3[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]siegenv[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]4[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]siegenp[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]5[/COLOR]</integer>[/COLOR]
            [COLOR=#b717a2]<key>[/COLOR]niednver[COLOR=#b717a2]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]6[/COLOR]</integer>[/COLOR]
            [COLOR=#b717a2]<key>[/COLOR]unenschieden[COLOR=#b717a2]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]8[/COLOR]</integer>[/COLOR]
            [COLOR=#b717a2]<key>[/COLOR]siegenver[COLOR=#b717a2]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]7[/COLOR]</integer>[/COLOR]
            [COLOR=#b717a2]<key>[/COLOR]niederlagen[COLOR=#b717a2]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]9[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]siege[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]10[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]punkte[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]20[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]name[/COLOR]</key>[/COLOR]
            [COLOR=#b717a2]<string>[/COLOR]Rapperswil-Jona Laker[COLOR=#b717a2]</string>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]        [/COLOR]</dict>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]        [/COLOR]<dict>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]rang[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]2[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]bgoal[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]20[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]sgoals[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]30[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]siegenv[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]40[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]siegenp[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]50[/COLOR]</integer>[/COLOR]
            [COLOR=#b717a2]<key>[/COLOR]niednver[COLOR=#b717a2]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]60[/COLOR]</integer>[/COLOR]
            [COLOR=#b717a2]<key>[/COLOR]unenschieden[COLOR=#b717a2]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]70[/COLOR]</integer>[/COLOR]
            [COLOR=#b717a2]<key>[/COLOR]siegenver[COLOR=#b717a2]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]80[/COLOR]</integer>[/COLOR]
            [COLOR=#b717a2]<key>[/COLOR]niederlagen[COLOR=#b717a2]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]90[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]siege[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]100[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]punkte[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<integer>[COLOR=#000000]200[/COLOR]</integer>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<key>[COLOR=#000000]name[/COLOR]</key>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]            [/COLOR]<string>[COLOR=#000000]Kloten Flyers[/COLOR]</string>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]        [/COLOR]</dict>[/COLOR]
[COLOR=#b717a2][COLOR=#000000]    [/COLOR]</array>[/COLOR]
[COLOR=#b717a2]</dict>[/COLOR]
[COLOR=#b717a2]</plist>[/COLOR]
 

DanHard

Roter Delicious
Registriert
05.08.11
Beiträge
94
Hat niemand einen Ansatz?
Danke vielmals.
 

Thyraz

London Pepping
Registriert
14.05.08
Beiträge
2.050
Mit Custom Cells kannst du an sich schon mehrere Informationen nebeneinander darstellen, als ob die TableView aus mehreren Spalten bestehen würde.
Einfach mehrere Labels nebeneinander anordnen innerhalb der TableViewCell und entsprechend befüllen.

Ich würde dann die Plists aber anders aufbauen.

Ein Array wo jedes Unterobjekt eine Zeile repräsentiert.
Diese Unterobjekte eben dann als Dicts mit Keys wie Name, Rang oder was du sonst noch zu jedem Verein hast.

In cellForRowAtIndexPath kannst du dann einfach beim Array mit objectAtIndex das passende Object abrufen und die Labels mit den Inhalten der entsprechenden Keys belegen.
 

DanHard

Roter Delicious
Registriert
05.08.11
Beiträge
94
Mit Custom Cells kannst du an sich schon mehrere Informationen nebeneinander darstellen, als ob die TableView aus mehreren Spalten bestehen würde.
Einfach mehrere Labels nebeneinander anordnen innerhalb der TableViewCell und entsprechend befüllen.

Ich würde dann die Plists aber anders aufbauen.

Ein Array wo jedes Unterobjekt eine Zeile repräsentiert.
Diese Unterobjekte eben dann als Dicts mit Keys wie Name, Rang oder was du sonst noch zu jedem Verein hast.

In cellForRowAtIndexPath kannst du dann einfach beim Array mit objectAtIndex das passende Object abrufen und die Labels mit den Inhalten der entsprechenden Keys belegen.

Danke für deine Hilfe.
Werts das Wochenende mal ausprobieren/anpassen.

Wie kann ich die plist Datei in ein Array laden, hadt du mit da einen Typ oder ein Stichwort, nach was ich in der Apple Hilfe suchen soll?!

Gute Nacht!
 

Answer

Wohlschmecker aus Vierlanden
Registriert
25.06.09
Beiträge
238
So lade ich alle Werte aus einer Plist in ein Array (hier im Beispiel für ein UIPickerView)

arrayPicker1 = [[NSMutableArray alloc] init];// Erstellt eine Pointer zum dictionary. KP warum, hab ich aus einem Tutorial
NSMutableDictionary *dictionary;
// liest die Datei "AllList.plist", welche sich unter "Resources" bzw. "Other Source" bei Universal Apps befindet, aus
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"AllList.plist"];
dictionary = [NSMutableDictionary dictionaryWithContentsOfFile:finalPath];


// Alle Einträge ins Array packen
for (id key in dictionary) {
[arrayPicker1 addObject:key];
}
 

DanHard

Roter Delicious
Registriert
05.08.11
Beiträge
94
Dankeschön! Meld mich dann obs geklappt hat! ;)