boredzo / iso-8601-date-formatter

A Cocoa NSFormatter subclass to convert dates to and from ISO-8601-formatted strings. Supports calendar, week, and ordinal formats.
http://boredzo.org/iso8601dateformatter/
Other
600 stars 140 forks source link

- (NSString *) stringFromDate:(NSDate *)date formatString:(NSString *)dateFormat timeZone:(NSTimeZone *)timeZone App got crashed. #80

Open shaikshabana opened 6 years ago

shaikshabana commented 6 years ago

Here is crash log:

0 libdispatch.dylib 0x1d3191be _dispatch_semaphore_dispose + 80 (semaphore.c:69) 1 Foundation 0x1e510b20 -[NSDateFormatter dealloc] + 74 (NSDateFormatter.m:291) 2 libobjc.A.dylib 0x1cee9258 objc_object::sidetable_release(bool) + 238 (NSObject.mm:1591) 3 ISO8601DateFormatter 0x0117e522 -[ISO8601DateFormatter stringFromDate:formatString:timeZone:] + 228 (ISO8601DateFormatter.m:716) 4 ISO8601DateFormatter 0x0117e3e6 -[ISO8601DateFormatter stringFromDate:timeZone:] + 132 (ISO8601DateFormatter.m:697)

When see code we are deallocating formatter but due to crash it's not going further steps where it's getting allocated.

if ([dateFormat isEqualToString:lastUsedFormatString] == NO) { [unparsingFormatter release]; unparsingFormatter = nil;

    [lastUsedFormatString release];
    lastUsedFormatString = [dateFormat retain];
}

if (!unparsingFormatter) {
    unparsingFormatter = [[NSDateFormatter alloc] init];
    unparsingFormatter.formatterBehavior = NSDateFormatterBehavior10_4;
    unparsingFormatter.dateFormat = dateFormat;
    unparsingFormatter.calendar = unparsingCalendar;
    unparsingFormatter.locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease];
}

Any inputs to fix this are welcome.