On Sun, Oct 9, 2011 at 1:51 PM, Jerry Krinock <je...@ieee.org> wrote:
>
> On 2011 Oct 08, at 21:12, Stephen J. Butler wrote:
>
>> What's wrong with +[NSDate distantFuture]?
>
> Nothing.  It's only [NSDate -dateWithTimeIntervalSinceNow:FLT_MAX] which 
> sometimes gives unexpected results.

It's not, at least not on 10.6 with Xcode 3.2.5. This program...


#import <Foundation/Foundation.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

    NSLog( @"distantFuture: %@", [NSDate distantFuture] );
    NSLog( @"FLT_MAX: %@", [NSDate dateWithTimeIntervalSinceNow:FLT_MAX] );

    [pool drain];
    return 0;
}


Gives the output (in 32 and 64 bit):


2011-10-09 14:46:41.639 Untitled[60937:a0f] distantFuture: 4000-12-31
18:00:00 -0600
2011-10-09 14:46:41.640 Untitled[60937:a0f] FLT_MAX: 5828963-12-19
18:00:00 -0600

I think you'll find distantFuture much less buggy than your solution,
seeing as how it isn't going to overflow or run into boundary
situations.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to