• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: timeIntervalSinceDate ????
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: timeIntervalSinceDate ????


  • Subject: Re: timeIntervalSinceDate ????
  • From: Stefan Jung <email@hidden>
  • Date: Thu, 27 Sep 2001 12:22:55 +0200

There are three problems.

On Donnerstag, September 27, 2001, at 03:10 Uhr, KyooHo Lee wrote:

NSDate *oldDate;
NSDate *currentDate;
NSDate *intervalDate;
NSTimeInterval intervalDate; or more obvious: intervalTime.

- (IBAction)start:(id)sender {
oldDate = [NSCalendarDate calendarDate];
oldDate = [[NSCalendarDate calendarDate] retain];

[sender setTitle : @"stop"];
[sender setAction : @selector(stop:)];
[startField setObjectValue : oldDate];
}

- (IBAction)stop:(id)sender {

currentDate = [NSCalendarDate calendarDate];

[sender setTitle : @"start"];
[sender setAction : @selector(start:)];
[stopField setObjectValue : currentDate];

intervalDate = [currentDate timeIntervalSinceDate:oldDate];
Three problems:
1. timeIntervalSinceDate: returns an NSTimeInterval which is essentially
a double and not an object of class NSDate.
2. oldDate is probably released, because the calendarDate method gives
you autoreleased object, so you hav to retain it, and release it
afterwards on your own. So you don't get a signal 10 SIGBUS error,
because oldDate was already released by the autorelease pool.
[secondsField setObjectValue : intervalDate];
3. As intervalDate is NOT an object but a double (or NSTimeInterval),
you have to make an object out of it.
[secondsField setObjectValue: [NSNumber numberWithDouble:
intervalDate]];
This works!

Fast advance,

Stefan Jung


References: 
 >timeIntervalSinceDate ???? (From: KyooHo Lee <email@hidden>)

  • Prev by Date: NSLineBreakMode
  • Next by Date: Re: How can I change IP address in the program?
  • Previous by thread: Re: timeIntervalSinceDate ????
  • Next by thread: Re: opposite of OOP (was file extensions)
  • Index(es):
    • Date
    • Thread