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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:19:53+00:00 2026-05-16T20:19:53+00:00

Hey i am trying to compare the date on which the user opens the

  • 0

Hey i am trying to compare the date on which the user opens the app to the date it is currently. (basically, how long they’ve had the app in days)

Here is the code:

- (NSInteger) daysAfterDate: (NSDate *) aDate
{
    NSTimeInterval ti = [self timeIntervalSinceDate:aDate]; //#1
    return (NSInteger) (ti / D_DAY); //#2
}  //#3

-(void)load {

        NSDate *birthdate = [prefs objectForKey:@"Birthdate"];

    rock_Age =  daysAfterDate(birthdate);

}

errors:

1.) it tells me incompatible types in initialization
2.) D_DAY Undecared

warning:

3.) control reaches end of non void function

If i did this completely wrong, (because for the life of me i cannot understand the NSDate class :/) I would gladly take an alternative to doing this 🙂

all help is appreciated,
Thank you
-Jackson Smith

  • 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-16T20:19:54+00:00Added an answer on May 16, 2026 at 8:19 pm

    The load method is correct, the following should work for -[daysAfterDate:].

    #define D_DAY        86400
    
    -(NSInteger)daysAfterDate:(NSDate *)aDate {
        NSTimeInterval ti = [[NSDate date] timeIntervalSinceDate:aDate];
        return (NSInteger) (ti / D_DAY);
    }
    

    1) is because self is probably no NSDate. Use [NSDate date] to get the current time/date.
    2) is because you have to define D_DAY
    3) only happens because of 2).

    I hope this helps.

    The following article might also be informative: (Ars Technica)

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

Sidebar

Related Questions

Hey i'm trying to build an app in which the user can input some
Hey trying to make a fancy little app here in VB.NET framework 4. I've
Hey in trying to submit my app to iTunes. It passes the validation, but
hey I'm trying to figure out what this element is in an app I
Hey basically Im trying to store a solution and create a vector of these.
Hey guys, I'm currently trying to implement a function using C that takes in
Hey i'm trying to display a date/time from a timestamp field using: echo $date
Hey im trying to implement bootstrap drop down in a text navbar here http://22twenty.com/V2
Hey I'm trying to compile the following piece of code to basically read stuff
Hey i'm trying to get the side with which the two objects in the

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.