0

I am currently using the below mentioned code to access a date column in parse and display in my custom tableview controller.

if var x = object?["columnName"] as? String {
   cell.Name.text = x;
}

One of the columns is a date field. Hence i tried with

if var lastModifiedTime = object?["columnName"] as? NSDate {
    var dateFormat = NSDateFormatter()
    dateFormat.dateFormat = "EEE, MMM d, h:mm a"
    cell.LastModifiedTime.text = NSString(format: "%@", dateFormat.stringFromDate(lastModifiedTime)) as String;
}

But the var is taking no values. I have checked in parse and the column type is Date. Can anyone please tell where am i going wrong

rafavinu
  • 305
  • 4
  • 20

1 Answers1

0

Check this out, this is in ObjC, but its basically the same as Swift for our purposes here:

PFObject * sh = [PFObject objectWithClassName:@"this"];
sh.createdAt
sh.updatedAt

You see, if you call to the dot notation of the PFObject, then you will get this values, there is no need to call it the way you are calling it

so, for you, it's like this, something like this:

if var lastModifiedTime = object .updatedAt NSDate {
Larry Pickles
  • 4,615
  • 2
  • 19
  • 36
  • Have tried the same thing above, it is not giving error, but the var does not contain any value!! (if var lastModifiedTime = object?["columnName"] as? NSDate) – rafavinu Aug 18 '15 at 07:50