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 7058153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:04:43+00:00 2026-05-28T04:04:43+00:00

Having a very odd problem. After processing of a file I read a txt

  • 0

Having a very odd problem. After processing of a file I read a txt which has three lines. Version, From Datetime, ToDatetime. I read these lines and add an object to NSCoreData. Everything works fine when running in a simulator but as soon as I deploy to my iPhone the NSDates come back as null.

Here is the console output when running from iPhone

2012-01-05 23:58:25.478 FlightPath[10257:707] 7/28/2011 12:00:00 AM
2012-01-05 23:58:27.911 FlightPath[10257:707] (null)
2012-01-05 23:58:29.718 FlightPath[10257:707] (null)

Here is the console output when running form iPhone Sim

2012-01-06 00:07:07.900 FlightPath[1755:11903] 7/28/2011 12:00:00 AM
2012-01-06 00:07:08.899 FlightPath[1755:11903] 7/28/2011 12:00:00 AM
2012-01-06 00:07:11.686 FlightPath[1755:11903] 7/28/2011 12:00:00 AM

Here is the code…I added in tDate for testing purposes. I wanted to make sure i didn’t need to add __block to the NSManagedObject.

NSString *mapInfoPath = [[mapData objectAtIndex:1] stringByAppendingPathComponent: @"Tiles/info.txt"];
        NSString *mapInfo = [[NSString alloc] initWithContentsOfFile:mapInfoPath encoding:NSUTF8StringEncoding error:nil];
        __block NSDate *tDate = nil;
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"M/d/yyyy h:mm:ss a"];

        __block int lineCount = 0;                
        [mapInfo enumerateLinesUsingBlock:^(NSString *line, BOOL *stop) {
            switch (lineCount) {
                case 1:
                    map.editionNumber = [NSNumber numberWithInt:[line intValue]];
                    break;
                case 2:   
                    tDate = [dateFormatter dateFromString:line]; 
                    map.fromDate = [dateFormatter dateFromString:line];
                    NSLog(@"%@", line);
                    NSLog(@"%@", [dateFormatter stringFromDate:map.fromDate]);
                    NSLog(@"%@", [dateFormatter stringFromDate:tDate]);
                    break;
                case 3:                            
                    map.toDate = [dateFormatter dateFromString:line];
                    break;
                default:
                    break;
            }

            lineCount += 1;
        }];
        map.processed = [NSNumber numberWithBool:YES];

Any help would be great….stuck and can’t figure out why it works on sim and not iPhone.

Thanks!

  • 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-05-28T04:04:43+00:00Added an answer on May 28, 2026 at 4:04 am

    Appears this is a bug when phone is in 24 hour mode. The direct answer was here: http://multinc.com/2009/09/27/iphone-sdk-time-bug-for-international-users/ which I found off of this post: Why my NSDate Formatter can't convert correctly and returns null on device?

    Since I always know I’ll be parsing a 12hr date time I just used setLocale and that did the trick.

    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setLocale: [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]];
    [dateFormatter setDateFormat:@"M/d/yyyy h:mm:ss aa"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having a very odd problem with Visual Studio 2010. After using it
I'm having a very odd problem in C# and I'm not sure what is
I'm having a very odd problem with grouping a set of nodes in a
Currently having this really odd problem with my layout IE7. I'm not very experienced
I seem to be having a very odd problem with my iPhone project in
I'm having a very odd problem that I can't seem to track down. Any
I am having a very odd problem with local variables being out of context
Im having a very strange problem, i have a complicated view that returns incorrect
I am having a very strange problem with pound signs displaying incorrectly (or not
We are having an odd problem with .NET Remoting. Basically, we have a server

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.