title: iOS getting date string from RSS Feed
body: <p>I have an XML parser that uses RaptureXML to grab each item and display it within a table cell.  I already can get the title and description, but I can't seem to work out how to get the date.</p>
  
  <p>Here's what I have so far for the date:</p>
  
  <pre><code>NSString* dateString;
  
  NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  [formatter setDateFormat:@"EEEE MMMM d, YYYY"];
  dateString = [formatter stringFromDate:self.pubDate];
  
  
  [articleAbstract appendAttributedString:
   [[NSAttributedString alloc] initWithString: dateString]
   ];
  </code></pre>
  
  <p>I keep getting this showing up in the debugger:</p>
  
  <pre><code>'NSInvalidArgumentException', reason: 'NSConcreteAttributedString initWithString:: nil value'
  </code></pre>
  
  <p>I don't know what I'm doing wrong. Here's the full code:</p>
  
  <p><strong>RSSItem.h</strong></p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  @interface RSSItem : NSObject
  
  @property (strong, nonatomic) NSString* title;
  @property (strong, nonatomic) NSString* description;
  @property (strong, nonatomic) NSURL* link;
  @property (strong, nonatomic) NSAttributedString* cellMessage;
  @property (strong, nonatomic) NSDate* pubDate;
  @property (strong, nonatomic) NSString* dateString;
  
  @end
  </code></pre>
  
  <p><strong>RSSItem.m</strong></p>
  
  <pre><code>#import "RSSItem.h"
  #import "GTMNSString+HTML.h"
  
  @implementation RSSItem
  
  -(NSAttributedString*)cellMessage
  </code></pre>
  
  <p>{
          if (_cellMessage!=nil) return _cellMessage;</p>
  
  <pre><code>NSDictionary* boldStyle = @{NSFontAttributeName: [UIFont fontWithName:@"Helvetica-Bold" size:16.0]};
  NSDictionary* normalStyle = @{NSFontAttributeName: [UIFont fontWithName:@"Helvetica" size:16.0]};
  
  NSMutableAttributedString* articleAbstract = [[NSMutableAttributedString alloc] initWithString:self.title];
  
  [articleAbstract setAttributes:boldStyle
                           range:NSMakeRange(0, self.title.length)];
  
  
  [articleAbstract appendAttributedString:
   [[NSAttributedString alloc] initWithString:@"\n\n"]
   ];
  
  // Parse for date
  
  NSString* dateString;
  
  NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  [formatter setDateFormat:@"EEEE MMMM d, YYYY"];
  dateString = [formatter stringFromDate:self.pubDate];
  
  
  [articleAbstract appendAttributedString:
   [[NSAttributedString alloc] initWithString: dateString]
   ];
  
  [articleAbstract appendAttributedString:
   [[NSAttributedString alloc] initWithString:@"\n\n"]
   ];
  
  int startIndex = [articleAbstract length];
  
  NSString* description = [NSString stringWithFormat:@"%@...", [self.description substringToIndex:100]];
  description = [description gtm_stringByUnescapingFromHTML];
  
  [articleAbstract appendAttributedString:
   [[NSAttributedString alloc] initWithString: description]
   ];
  
  [articleAbstract setAttributes:normalStyle
                           range:NSMakeRange(startIndex, articleAbstract.length - startIndex)];
  
  _cellMessage = articleAbstract;
  return _cellMessage;
  
  }
  
  @end
  </code></pre>
  
  <p><strong>EDIT: Here is my RSS Loader</strong></p>
  
  <pre><code>#import "RSSItem.h"
  
  #define kBgQueue dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)
  
  @implementation RSSLoader
  
  -(void)fetchRssWithURL:(NSURL*)url complete:(RSSLoaderCompleteBlock)c
  {
  dispatch_async(kBgQueue, ^{
  
      //work in the background
      RXMLElement *rss = [RXMLElement elementFromURL: url];
      RXMLElement* title = [[rss child:@"channel"] child:@"title"];        
      RXMLElement* pubDate = [[rss child:@"channel"] child:@"pubDate"];
  
      NSString *usableDate = [pubDate];       
  
      NSArray* items = [[rss child:@"channel"] children:@"item"];
  
      NSMutableArray* result = [NSMutableArray arrayWithCapacity:items.count];
  
      //more code
      for (RXMLElement *e in items) {
  
          //iterate over the articles
          RSSItem* item = [[RSSItem alloc] init];
          item.title = [[e child:@"title"] text];            
          item.pubDate = usableDate
          item.description = [[e child:@"description"] text];
          item.link = [NSURL URLWithString: [[e child:@"link"] text]];
          [result addObject: item];
      }
  
      c([title text], result);
  });
  
  }
  </code></pre>
  
  <p>Can someone please help me parse my date correctly?</p>