// Weddingdates.m Copyright (c) Kari Laitinen // http://www.naturalprogramming.com // 2013-07-15 Objective-C version of this file was created. // 2013-07-15 Last modification. // This program demonstrates the use of the following classes // ISODate // NSString // NSCharacterSet #include #import #import "class_isodate_oc.h" int main( void ) { NSAutoreleasePool* autorelease_pool = [ [ NSAutoreleasePool alloc ] init ] ; // At the beginning date_to_increment refers to an object that // contains the current computer date. ISODate* date_to_increment = [ [ ISODate alloc ] init ] ; int number_of_dates_printed = 0 ; printf( "\n These are easy-to-remember dates for weddings and" "\n other important events because the days and months" "\n consist of the digits used in the year: \n" ) ; while ( number_of_dates_printed < 60 ) { NSString* year_as_string = [ NSString stringWithFormat: @"%d", [ date_to_increment year ] ] ; NSString* month_as_string = [ NSString stringWithFormat: @"%d", [ date_to_increment month ] ] ; NSString* day_as_string = [ NSString stringWithFormat: @"%d", [ date_to_increment day ] ] ; NSCharacterSet* characters_in_year = [ NSCharacterSet characterSetWithCharactersInString: year_as_string ] ; NSCharacterSet* characters_in_month = [ NSCharacterSet characterSetWithCharactersInString: month_as_string ] ; NSCharacterSet* characters_in_day = [ NSCharacterSet characterSetWithCharactersInString: day_as_string ] ; if ( [ characters_in_year isSupersetOfSet: characters_in_month ] && [ characters_in_year isSupersetOfSet: characters_in_day ] ) { // Now we have found a date that meets our requirements. if ( number_of_dates_printed % 5 == 0 ) { printf( "\n" ) ; } NSString* text_to_print = [ NSString stringWithFormat: @" %@", date_to_increment ] ; printf( "%s", [ text_to_print UTF8String ] ) ; number_of_dates_printed ++ ; } [ date_to_increment increment ] ; } printf( "\n\n" ) ; [ autorelease_pool drain ] ; } // During compilation class_isodate_oc.h must be in the same folder // with this program.