NSDateFormatter Fail

Discussion in 'iOS Programming' started by hiddenpremise, May 17, 2009.

  1. hiddenpremise macrumors regular

    hiddenpremise

    Joined:
    Jul 25, 2008
    Location:
    Somewhere between my imagination and reality
    #1
    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);
     
  2. CocoaPuffs macrumors 68010

    Joined:
    Aug 23, 2008
    #2
    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.
     
  3. hiddenpremise thread starter macrumors regular

    hiddenpremise

    Joined:
    Jul 25, 2008
    Location:
    Somewhere between my imagination and reality
    #3
    My best guess is that i needed to run a clean, because this is working now...
     

Share This Page