Reputation: 247
I am having trouble using cellForRowAtIndexPath in a tableView from Parse.com The code I am running is:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("ListadoInventarioCell", forIndexPath: indexPath) as UITableViewCell
var sectionTitle:String = timelineData1.objectAtIndex(indexPath.section) as String
var sectionAnimals:Array = porBodega[sectionTitle]!
// This is the line with problems
var animal:String = sectionAnimals.objectAtIndex(indexPath.row) as String
cell.textLabel?.text = animal
}
Problem is variable porBodega is a Dictionary of type String: ArrayOfPFObject , so sectionAnimals is an array of PFObjects. If I do a println(porBodega), I get this:
[Oficina: [
<InventarioObjetos:wObhxQ98oz:(null)> {
Bodega = Oficina;
Categoria = "Equipo de monta\U00f1a";
Descripcion = Chalecos;
FechaDeEntrada = "2012-04-01 19:44:00 +0000";
Marca = "O'rageous";
Modelo = "VM-001";
NumeroDeInventario = CSOV002;
NumeroDeSerie = NA;
Status = Usado;
Tamano = M;
},
<InventarioObjetos:u3Yn80lXU8:(null)> {
Bodega = Oficina;
Categoria = "Equipo de monta\U00f1a";
Descripcion = Chalecos;
FechaDeEntrada = "2012-04-01 19:44:00 +0000";
Marca = "O'rageous";
Modelo = "VM-001";
NumeroDeInventario = CSOV003;
NumeroDeSerie = NA;
Status = Usado;
Tamano = M;
}
]]
So I do not know how to get a specific data form one of my objects, like the variable Modelo and then set it up in the cell text label. Any ideas??
Upvotes: 0
Views: 299
Reputation: 45490
EDIT:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("ListadoInventarioCell", forIndexPath: indexPath) as UITableViewCell
var sectionTitle:String = timelineData1.objectAtIndex(indexPath.section) as String
var sectionAnimals:Array = porBodega[sectionTitle]!
let animal:PFObject = sectionAnimals[indexPath.row] as PFObject
cell.textLabel?.text = animal.objectForKey("modelo") as String
}
Upvotes: 1