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

  • Home
  • SEARCH
  • 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 1036875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:46:31+00:00 2026-05-16T14:46:31+00:00

So I am new to the development thing, making me yes a noob. I

  • 0

So I am new to the development thing, making me yes a noob.
I am currently creating my first iPhone app and in it I have a countdown relating to when a web video service is launching.
Under the countdown I have a button that allows playing the video stream, I would like to create an if statement that tells the app to reference the iPhone current date and if it is over the launch date then the iPhone will launch the video stream, if the user presses the button before the launch date I would like a UIAlert View to appear saying the date of the service launch, so far I have this.

- (IBAction)watchLive { 

    self.today = [NSDate date];
    NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];
    [dateformatter setDateFormat:@"MM/dd/yyyy hh:mm:ss"];
    NSString *launchDay = [[NSString alloc] initWithString:@"11/26/2010 11:59:59"];
    NSDate *currentDate = [dateformatter dateFromString:launchDay];

    NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
    int unitFlags = NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
    NSDateComponents *components = [gregorian components:unitFlags fromDate:today toDate:currentDate options:0];
    countdownLabel.text = [NSString stringWithFormat:@"%02d:%02d:%02d:%02d", components.day, components.hour, components.minute, components.second ];

    if (today >= currentDate){

        UIAlertView*alert = [[UIAlertView alloc] initWithTitle:@"Coming Soon" message:@"Feed goes live Friday 26th November 12:00pm" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }       
    else {
        UIAlertView*alert =[[UIAlertView alloc] initWithTitle:@"Perfect" message:@"It Works" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
        [alert show];
        [alert release];        
    }    
}

Any help is greatly appreciated as I really am not sure how I am going wrong or what i should have in place.

Oh yes one last thing, when I run the App in the simulator and on device, it just randomly displays one of the messages, and I cannot determine what causes each message to display but it isn’t the date!

Thanks guys!
Phil

  • 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-16T14:46:31+00:00Added an answer on May 16, 2026 at 2:46 pm

    When comparing dates you should use the comparison methods of NSDate
    The behaviour you are seeing is a result of comparing the memory addresses of today and currentDate

    Change

    if (today >= currentDate)
    

    To

    if ([today timeIntervalSinceDate:currentDate] <= 0 ) // today is before launch
    

    Refer to the NSDate Class Reference for more detail

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

Sidebar

Related Questions

I'm very new to iPhone development and I'm making an application where I have
I'm new to JBoss Seam and Java web app development in general. One thing
I'm new to the whole iOS development thing but I have completed my first
I'm new to PHP (and web development in general) and have come across something
I'm a long-time web guy who's pretty new to iphone development. I'm finding many
I am new to iPhone development, i have implemented paypal sdk in my iPhone
i am new to iphone development.. i am making an application in which table
I'm fairly new to web development and I'd like to think I am getting
i'm new here, i'm new in iphone development, i'm new in Objective-c and i'm
i am new to iPad development. I am making iPad applications. In my application

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.