dateWithNaturalLanguageString SOLUTION

Hi there! Now dateWithNaturalLanguageString doesn’t work in XCODE 7, and here’s my solution, enjoy:D

#import <Foundation/Foundation.h>
#import "BNREmployee.h"

int main(int argc, const char * argv[])
{
    @autoreleasepool {
        
        // Create an instance of BNREmployee
        BNREmployee *mikey = [[BNREmployee alloc] init];
        
        // Give the instance variables interesting values using setter methods
        mikey.weightInKilos = 96;
        mikey.heightInMeters = 1.8;
        mikey.employeeID = 12;
        
        //Specifying date
        NSDateComponents *components = [NSDateComponents new];
        [components setYear:2010];
        [components setDay:2];
        [components setMonth:8];
        
        //We need this calendar so that we can use -dateFromComponents function:)
        NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier: NSCalendarIdentifierGregorian];
        
        
        
        //Assigning final date to our Object/Employee
        mikey.hireDate = [gregorian dateFromComponents: components];
        
        
        //Giving date nice look (Aug %day, %year)
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        dateFormatter.timeStyle = NSDateFormatterNoStyle;
        dateFormatter.dateStyle = NSDateFormatterMediumStyle;
        
        //Displays time in ENG (or localization), i get russian output by default without these two lines: Август 2, 2010
        NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
        [dateFormatter setLocale];
        
        //Applying dateFormatter to our date(mikey.hireDate), because it needs to look fancy... the result will be string, i just don't know how to make mikey.hireDate look right (%month %day, %year) without converting it to String    :}
        NSString *finalDateItsStringNow = [dateFormatter stringFromDate:mikey.hireDate];
        
        // Log the instance variables using the getters
        float height = mikey.heightInMeters;
        int weight = mikey.weightInKilos;
        NSLog(@"mikey is %.2f meters tall and weighs %d kilos", height, weight);
        NSLog(@"Employee %u hired on %@", mikey.employeeID, finalDateItsStringNow);
        
        // Log the body mass index using the bodyMassIndex method
        float bmi = [mikey bodyMassIndex];
        double years = [mikey yearsOfEmployment];
        NSLog(@"BMI of %.2f, has worked with us for %.2f years", bmi, years);
    }
    return 0;
}

Output:

[quote]-----mikey is 1.80 meters tall and weighs 96 kilos
-----Employee 12 hired on Aug 2, 2010
-----BMI of 29.63, has worked with us for 5.37 years
-----Program ended with exit code: 0[/quote]