diff --git a/KosherCocoa.xcodeproj/project.pbxproj b/KosherCocoa.xcodeproj/project.pbxproj index 35314bc..175e5a6 100644 --- a/KosherCocoa.xcodeproj/project.pbxproj +++ b/KosherCocoa.xcodeproj/project.pbxproj @@ -1011,7 +1011,7 @@ 46DB49631D9839F100F3A576 = { CreatedOnToolsVersion = 8.0; DevelopmentTeam = HK64RUWW3P; - LastSwiftMigration = 0900; + LastSwiftMigration = 0920; ProvisioningStyle = Automatic; }; }; @@ -1721,7 +1721,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_SWIFT3_OBJC_INFERENCE = On; SWIFT_VERSION = 4.0; }; name = Debug; @@ -1748,7 +1748,7 @@ MTL_ENABLE_DEBUG_INFO = NO; PRODUCT_BUNDLE_IDENTIFIER = com.mosheberman.KosherCocoaTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_SWIFT3_OBJC_INFERENCE = On; SWIFT_VERSION = 4.0; }; name = Release; diff --git a/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.h b/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.h index 1332f39..8e1dc79 100644 --- a/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.h +++ b/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.h @@ -117,17 +117,40 @@ NS_SWIFT_NAME(SefiraFormatter) - (nullable NSString *)countStringFromInteger:(NSInteger)integer withPrayers:(KCSefiraPrayerAddition)prayers; +#pragma mark - Getting the Kabbalistic Trait of the Week + +/** + Converts an integer (between 1 and 7, inclusive) + into a kabbalistic trait traditionally assigned + to a given week of the omer. + + @param week The week to get the trait for. + @return A string containing the attribure of that week. + */ +- (nullable NSString *)kabbalisticTraitForWeek:(NSInteger)week; + + #pragma mark - Getting the Kabbalistic Trait of the Day /** - * Converts an integer (between 1 and 49, inclusive) - * into a kabbalistic trait traditionally assigned - * to a given day of the omer. - * - * @return A string containing the attribure of that day. + Converts an integer (between 1 and 49, inclusive) + into a kabbalistic trait traditionally assigned + to a given day of the omer. + + @param day The day to get the trait for. + @return A string containing the attribure of that day. */ +- (nullable NSString *)kabbalisticTraitForDay:(NSInteger)day; -- (nullable NSString *)kabbalisticTraitFromInteger:(NSInteger)integer; +/** + Converts an integer (between 1 and 49, inclusive) + into a kabbalistic trait traditionally assigned + to a given day of the omer. + + @param integer The day to get the trait for. + @return A string containing the attribure of that day. + */ +- (nullable NSString *)kabbalisticTraitFromInteger:(NSInteger)integer DEPRECATED_MSG_ATTRIBUTE("Use kabbalisticTraitForDay: and kabbalisticTraitForWeek: instead."); /** * Get the blessing text for counting the omer. diff --git a/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.m b/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.m index ebf8978..b7aff59 100644 --- a/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.m +++ b/KosherCocoa/Library/Core/Calendar/Sefira/KCSefiraFormatter.m @@ -30,6 +30,7 @@ @interface KCSefiraFormatter () @property (nonatomic, strong) NSArray <NSString *> *englishKabbalisticStrings; @property (nonatomic, strong) NSArray <NSString *> *hebrewKabbalisticStrings; @property (nonatomic, strong) NSArray <NSString *> *transliteratedHebrewKabbalisticStrings; +@property (nonatomic, strong) NSArray <NSString *> *sefirahNamesByWeek; @end @@ -259,57 +260,30 @@ - (nonnull id)init _sefardTransliteratedStrings = @[]; _sephardicTransliteratedStrings = @[]; - _hebrewKabbalisticStrings = @[ - @"חֶסֶד שֶבְּחֶסֶד", - @"גְבוּרָה שֶבְּחֶסֶד", - @"תִּפֶארֶת שֶבְּחֶסֶד", - @"נֶצַח שֶבְּחֶסֶד", - @"הוֹד שֶבְּחֶסֶד", - @"יְסֹוד שֶבְּחֶסֶד", - @"מַלְכוּת שֶבְּחֶסֶד", - @"חֶסֶד שֶבְּגְבוּרָה", - @"גְבוּרָה שֶבְּגְבוּרָה", - @"תִּפֶארֶת שֶבְּגְבוּרָה", - @"נֶצַח שֶבְּגְבוּרָה", - @"הוֹד שֶבְּגְבוּרָה", - @"יְסֹוד שֶבְּגְבוּרָה", - @"מַלְכוּת שֶבְּגְבוּרָה", - @"חֶסֶד שֶבְּתִּפֶארֶת", - @"גְבוּרָה שֶבְּתִּפֶארֶת", - @"תִּפֶארֶת שֶבְּתִּפֶארֶת", - @"נֶצַח שֶבְּתִּפֶארֶת", - @"הוֹד שֶבְּתִּפֶארֶת", - @"יְסֹוד שֶבְּתִּפֶארֶת", - @"מַלְכוּת שֶבְּתִּפֶארֶת", - @"חֶסֶד שֶבְּנֶצַח", - @"גְבוּרָה שֶבְּנֶצַח", - @"תִּפֶארֶת שֶבְּנֶצַח", - @"נֶצַח שֶבְּנֶצַח", - @"הוֹד שֶבְּנֶצַח", - @"יְסֹוד שֶבְּנֶצַח", - @"מַלְכוּת שֶבְּנֶצַח" - , @"חֶסֶד שֶבְּהוֹד", - @"גְבוּרָה שֶבְּהוֹד", - @"תִּפֶארֶת שֶבְּהוֹד", - @"נֶצַח שֶבְּהוֹד", - @"הוֹד שֶבְּהוֹד", - @"יְסֹוד שֶבְּהוֹד", - @"מַלְכוּת שֶבְּהוֹד", - @"חֶסֶד שֶבְּיְסֹוד", - @"גְבוּרָה שֶבְּיְסֹוד", - @"תִּפֶארֶת שֶבְּיְסֹוד", - @"נֶצַח שֶבְּיְסֹוד", - @"הוֹד שֶבְּיְסֹוד", - @"יְסֹוד שֶבְּיְסֹוד", - @"מַלְכוּת שֶבְּיְסֹוד", - @"חֶסֶד שֶבְּמַלְכוּת", - @"גְבוּרָה שֶבְּמַלְכוּת", - @"תִּפֶארֶת שֶבְּמַלְכוּת", - @"נֶצַח שֶבְּמַלְכוּת", - @"הוֹד שֶבְּמַלְכוּת", - @"יְסֹוד שֶבְּמַלְכוּת", - @"מַלְכוּת שֶבְּמַלְכוּת" - ]; + _sefirahNamesByWeek = @[ + @"חֶסֶד", + @"גְבוּרָה", + @"תִּפֶארֶת", + @"נֶצַח", + @"הוֹד", + @"יְסֹוד", + @"מַלְכוּת" + ]; + NSMutableArray <NSString *>* hebrewKabbalisticStrings = [@[] mutableCopy]; + + for (NSInteger i = 0; i<_sefirahNamesByWeek.count; i++) { + for (NSInteger j = 0; j<_sefirahNamesByWeek.count; j++) { + NSString *part1 = _sefirahNamesByWeek[j]; + NSString *part2 = @"שֶבְּ"; + NSString *part3 = _sefirahNamesByWeek[i]; + + NSString *trait = [NSString stringWithFormat:@"%@ %@%@", part1, part2, part3]; + [hebrewKabbalisticStrings addObject:trait]; + } + } + + _hebrewKabbalisticStrings = hebrewKabbalisticStrings; + _englishKabbalisticStrings = @[]; _transliteratedHebrewKabbalisticStrings = @[]; } @@ -460,7 +434,7 @@ - (nullable NSString *)countStringFromInteger:(NSInteger)integer withPrayers:(en if (showRibono) { - NSString *trait = [self kabbalisticTraitFromInteger:integer]; + NSString *trait = [self kabbalisticTraitForDay:integer]; ribono = [NSString stringWithFormat:@"רִבּוֹנוֹ שֶׁל עוֹלָם, אַתָּה צִוִּיתָֽנוּ עַל יְדֵי מֹשֶׁה עַבְדֶּֽךָ לִסְפּוֹר סְפִירַת הָעֹֽמֶר, כְּדֵי לְטַהֲרֵֽנוּ מִקְּלִפּוֹתֵֽינוּ וּמִטֻּמְאוֹתֵֽינוּ, כְּמוֹ שֶׁכָּתַֽבְתָּ בְּתוֹרָתֶֽךָ: וּסְפַרְתֶּם לָכֶם מִמָּחֳרַת הַשַּׁבָּת מִיּוֹם הֲבִיאֲכֶם אֶת עֹֽמֶר הַתְּנוּפָה, שֶֽׁבַע שַׁבָּתוֹת תְּמִימֹת תִּהְיֶֽינָה, עַד מִמָּחֳרַת הַשַּׁבָּת הַשְּׁבִיעִת תִּסְפְּרוּ חֲמִשִּׁים יוֹם, כְּדֵי שֶׁיִּטָּהֲרוּ נַפְשׁוֹת עַמְּךָ יִשְׂרָאֵל מִזֻּהֲמָתָם. וּבְכֵן יְהִי רָצוֹן מִלְּפָנֶֽיךָ יְיָ אֱלֹהֵֽינוּ וֵאלֹהֵי אֲבוֹתֵֽינוּ, שֶׁבִּזְכוּת סְפִירַת הָעֹֽמֶר שֶׁסָּפַֽרְתִּי הַיּוֹם, יְתֻקַּן מַה שֶּׁפָּגַֽמְתִּי בִּסְפִירָה %@ וְאֶטָּהֵר וְאֶתְקַדֵּשׁ בִּקְדֻשָּׁה שֶׁל מַֽעְלָה, וְעַל יְדֵי זֶה יֻשְׁפַּע שֶֽׁפַע רַב בְּכָל הָעוֹלָמוֹת, וּלְתַקֵּן אֶת נַפְשׁוֹתֵֽינוּ וְרוּחוֹתֵֽינוּ וְנִשְׁמוֹתֵֽינוּ מִכָּל סִיג וּפְגַם, וּלְטַהֲרֵֽנוּ וּלְקַדְּשֵֽׁנוּ בִּקְדֻשָּׁתְךָ הָעֶלְיוֹנָה, אָמֵן סֶֽלָה.", trait]; @@ -481,30 +455,61 @@ - (nullable NSString *)countStringFromInteger:(NSInteger)integer withPrayers:(en return output; } -#pragma mark - Getting the Kabbalistic Trait of the Day +#pragma mark - Getting the Kabbalistic Trait of the Week /** - * Converts an integer (between 1 and 49, inclusive) - * into a kabbalistic trait traditionally assigned - * to a given day of the omer. - * - * @return A string containing the attribure of that day. + Converts an integer (between 1 and 7, inclusive) + into a kabbalistic trait traditionally assigned + to a given week of the omer. + + @param week The week to get the trait for. + @return A string containing the attribure of that week. */ +- (nullable NSString *)kabbalisticTraitForWeek:(NSInteger)week; +{ + if (week > 7 || week < 1) { + return nil; + } + return self.sefirahNamesByWeek[week - 1]; +} -- (nullable NSString *)kabbalisticTraitFromInteger:(NSInteger)integer +#pragma mark - Getting the Kabbalistic Trait of the Day + +/** + Converts an integer (between 1 and 49, inclusive) + into a kabbalistic trait traditionally assigned + to a given day of the omer. + + @param day The day to get the trait for. + @return A string containing the attribure of that day. + */ +- (nullable NSString *)kabbalisticTraitForDay:(NSInteger)day; { NSString *trait = nil; - integer = integer - 1; + day = day - 1; - if (integer < self.hebrewKabbalisticStrings.count) + if (day < self.hebrewKabbalisticStrings.count) { - trait = self.hebrewKabbalisticStrings[integer]; + trait = self.hebrewKabbalisticStrings[day]; } return trait; } +/** + * Converts an integer (between 1 and 49, inclusive) + * into a kabbalistic trait traditionally assigned + * to a given day of the omer. + * + * @return A string containing the attribure of that day. + */ + +- (nullable NSString *)kabbalisticTraitFromInteger:(NSInteger)integer +{ + return [self kabbalisticTraitForDay:integer]; +} + #pragma mark - Helpers /**