Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hiddenpremise

macrumors regular
Original poster
This code keeps returning NULL and I can't for the life of me understand why

Code:
NSString *pubDate = @"Tue, 30 Sep 2008 19:45:23 -0400";
	
	//remove the time, returns: Tue, 30 Sep 2008
	NSString *subStringPubDate = [pubDate substringWithRange:NSMakeRange(0, 16)];
	
	//create formatter and format
	NSDateFormatter *dtsFormatter = [[[NSDateFormatter alloc] init]  autorelease];
	[dtsFormatter setDateFormat:@"EEE, d MMM yyyy"];
	
	//run the string through the formatter
	NSDate *formattedDate = [dtsFormatter dateFromString:subStringPubDate];
	NSLog(@"%@", formattedDate);
 

CocoaPuffs

macrumors 68020
Aug 23, 2008
2,005
3
Problem must lie within:

Code:
//remove the time, returns: Tue, 30 Sep 2008
	NSString *subStringPubDate = [pubDate substringWithRange:NSMakeRange(0, 16)];

NSLog subStringPubDate and see if that returns nil.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.