Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8893149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:10:31+00:00 2026-06-14T23:10:31+00:00

I have an XML parser that uses RaptureXML to grab each item and display

  • 0

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.

Here’s what I have so far for the 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]
 ];

I keep getting this showing up in the debugger:

'NSInvalidArgumentException', reason: 'NSConcreteAttributedString initWithString:: nil value'

I don’t know what I’m doing wrong. Here’s the full code:

RSSItem.h

#import <Foundation/Foundation.h>

@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

RSSItem.m

#import "RSSItem.h"
#import "GTMNSString+HTML.h"

@implementation RSSItem

-(NSAttributedString*)cellMessage

{
if (_cellMessage!=nil) return _cellMessage;

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

EDIT: Here is my RSS Loader

#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);
});

}

Can someone please help me parse my date correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:10:32+00:00Added an answer on June 14, 2026 at 11:10 pm

    Based on the code you added to your question, the problem has to do with how you set the pubDate property. You defined the property to be an NSDate but you set an NSString value to the property in your RSS loader code.

    You need to convert the string obtained from the XML file to an NSDate or change your pubDate property from NSDate to NSString. If you do the latter then your earlier code needs to be updated to reflect this change.

    The decision is really dependent on what you need to do with the date.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a XML parser that list correctly in the UITableViewController. It passes
I have a buggy xml that contains empty attributes and I have a parser
Is there any tool that can parse/conver xml files to this format? I have
Currently I am trying to parse an xml string that I already have (no
I have taken over the maintenance of an application that uses a stax parser
I have an application that uses xml config file, where I'm describing layouts for
I have a multithreaded server C++ program that uses MSXML6 and continuously parses XML
I have XML in the following form that I want to parse with PHP
I want to parse xml files that have elements like these: <element>&amp</element> <element>&amp;</element> But
I currently have a Perl CGI script that parses incoming XML requests using XML::Simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.