Note that there are some explanatory texts on larger screens.

plurals
  1. POXcode iPhone Date Formatting issue
    primarykey
    data
    text
    <p>I can't for the life of me figure out why my code wont format the date when it has worked for me before so I figured I would post the code up and see if someone else could spot the issue..</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *MyIdentifier = @"MyIdentifier"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:MyIdentifier] autorelease]; } // Set up the cell int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1]; cell.textLabel.text = [[stories objectAtIndex: storyIndex] objectForKey: @"title"]; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat: @"yyyy-MM-dd HH:mm:ss zzz"]; NSDate *dateTmp; dateTmp = [[stories objectAtIndex:storyIndex]objectForKey: @"date"]; cell.detailTextLabel.text = [dateFormat stringFromDate:dateTmp]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; cell.textLabel.font=[UIFont fontWithName:@"Verdana" size:12.0]; cell.detailTextLabel.textColor = Light_BACKGROUND; [dateFormat release]; return cell; </code></pre> <p>}</p> <p>I have used nslogs to see what information the code is actually making happen and it would seem that it has no problem getting the date from the mutable array but when I try to apply the stringFromDate for the detail text it just returns null so nothing is being placed leaving the detail text blank.</p> <p>I attempted to set a string so I could check the log and this was the turn out.</p> <pre><code>[1984:207] all done! [1984:207] stories array has 10 items [1984:207] DateTmp = Wed, 16 Feb 2011 01:37:16 +0000 [1984:207] DateLine = (null) [1984:207] DateTmp = Tue, 15 Feb 2011 23:05:31 +0000 [1984:207] DateLine = (null) [1984:207] DateTmp = Tue, 15 Feb 2011 04:31:36 +0000 [1984:207] DateLine = (null) [1984:207] DateTmp = Tue, 15 Feb 2011 02:16:01 +0000 [1984:207] DateLine = (null) [1984:207] DateTmp = Sun, 13 Feb 2011 04:07:42 +0000 [1984:207] DateLine = (null) [1984:207] DateTmp = Sun, 13 Feb 2011 02:15:41 +0000 [1984:207] DateLine = (null) [1984:207] DateTmp = Sun, 13 Feb 2011 00:21:42 +0000 [1984:207] DateLine = (null) [1984:207] DateTmp = Sat, 12 Feb 2011 22:50:27 +0000 [1984:207] DateLine = (null) [1984:207] DateTmp = Sat, 12 Feb 2011 21:07:27 +0000 [1984:207] DateLine = (null) </code></pre> <p>Thanks for the help.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload