1

I have a parse backend, and I am putting at the rows into an array in swift, and then displaying them in a tableview. All the labels are fine and I am having trouble with an Image column (PFFile).

Here is my code to retrieve the data and place into an array

  var GetAllEvents : PFQuery = PFQuery(className: "Types_")
        GetAllEvents.findObjectsInBackgroundWithBlock{
            (objects:[AnyObject]!, error:NSError!) ->Void in

            if (error == nil) {
                for object in objects {
                    self.EventData.addObject(object)
                    println(object)


                self.tableView.reloadData()
            }

Then I retrieve the content in cellforindexpath , like this :

cell.EventTitle.text = (event.objectForKey("Title") as String!)
cell.EventType.text = (event.objectForKey("TypeOfVenue_") as String!)

I am having trouble with the image , I have written this :

cell.TypeImage.image = (event.objectForKey("TyoeImage") as PFFile)

but as UIImage is not a PFFile, it shows an error. Whats the best way to display this image ?

thanks

Jason
  • 1,057
  • 3
  • 13
  • 31
  • 1
    Jason, see my answer here : http://stackoverflow.com/questions/27595220/downloading-pffile-image-from-parse-append-it-to-array-and-fill-uiimageview-wi/27596932#27596932 – soulshined Jan 03 '15 at 12:16
  • Hi there, yes I have already looked at your answer but I done want to download twice, as its a waste! – Jason Jan 03 '15 at 12:28
  • What do you mean download twice – soulshined Jan 03 '15 at 13:01
  • well I used [anyobject] to download all the strings and files, then I cast them AS String and I thought id be able to case the file as NSData. without doing another download block. but with your idea I have a download block for strings and then one for PFFiles. – Jason Jan 03 '15 at 13:33
  • You can use the same download block. I was simply pointing you to the right direction for the correct syntax of downloading images from parse – soulshined Jan 03 '15 at 13:36
  • Objectforkey is wrong, especially your syntax. PFFiles aren't objects and images are especially data. So just use the link or any other link it doesn't have to be mine. I was just trying to guide you through the correct syntax and don't want to answer on a duplicated question. – soulshined Jan 03 '15 at 13:40

0 Answers0