<small id='uwMS6'></small><noframes id='uwMS6'>

  • <tfoot id='uwMS6'></tfoot>

        <bdo id='uwMS6'></bdo><ul id='uwMS6'></ul>

        <legend id='uwMS6'><style id='uwMS6'><dir id='uwMS6'><q id='uwMS6'></q></dir></style></legend>

        <i id='uwMS6'><tr id='uwMS6'><dt id='uwMS6'><q id='uwMS6'><span id='uwMS6'><b id='uwMS6'><form id='uwMS6'><ins id='uwMS6'></ins><ul id='uwMS6'></ul><sub id='uwMS6'></sub></form><legend id='uwMS6'></legend><bdo id='uwMS6'><pre id='uwMS6'><center id='uwMS6'></center></pre></bdo></b><th id='uwMS6'></th></span></q></dt></tr></i><div id='uwMS6'><tfoot id='uwMS6'></tfoot><dl id='uwMS6'><fieldset id='uwMS6'></fieldset></dl></div>

        Objective-C:将数字格式化为序数:1, 2, 3, .. to 1st, 2

        时间:2023-08-31
      1. <i id='KO7AN'><tr id='KO7AN'><dt id='KO7AN'><q id='KO7AN'><span id='KO7AN'><b id='KO7AN'><form id='KO7AN'><ins id='KO7AN'></ins><ul id='KO7AN'></ul><sub id='KO7AN'></sub></form><legend id='KO7AN'></legend><bdo id='KO7AN'><pre id='KO7AN'><center id='KO7AN'></center></pre></bdo></b><th id='KO7AN'></th></span></q></dt></tr></i><div id='KO7AN'><tfoot id='KO7AN'></tfoot><dl id='KO7AN'><fieldset id='KO7AN'></fieldset></dl></div>
          <bdo id='KO7AN'></bdo><ul id='KO7AN'></ul>

            • <small id='KO7AN'></small><noframes id='KO7AN'>

                    <tbody id='KO7AN'></tbody>
                  <tfoot id='KO7AN'></tfoot>
                  <legend id='KO7AN'><style id='KO7AN'><dir id='KO7AN'><q id='KO7AN'></q></dir></style></legend>
                  本文介绍了Objective-C:将数字格式化为序数:1, 2, 3, .. to 1st, 2nd, 3rd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  在 Objective C 中,有没有办法将 integer 格式化为序数1 => "1st"、2 => "2nd" 等...适用于任何语言?因此,如果用户是法国人,他会看到1er"、2ieme"等.

                  In Objective C, is there any way to format an integer to ordinals 1 => "1st", 2 => "2nd" etc... that works for any language? So if the user is French he will see "1er", "2ieme" etc..

                  非常感谢!

                  编辑:这是一个 iOS 应用程序

                  Edit: This is for an iOs app

                  推荐答案

                  你有没有看过 TTTOrdinalNumberFormatter" rel="noreferrer">FormatterKit?它工作得很好,我很确定这正是您正在寻找的.

                  Have you taken a look at TTTOrdinalNumberFormatter which is in FormatterKit? It works great, and I'm pretty sure it's exactly what you're looking for.

                  这是一个从套件中提取的示例:

                  Here's an example taken from the kit:

                  TTTOrdinalNumberFormatter *ordinalNumberFormatter = [[TTTOrdinalNumberFormatter alloc] init];
                  [ordinalNumberFormatter setLocale:[NSLocale currentLocale]];
                  [ordinalNumberFormatter setGrammaticalGender:TTTOrdinalNumberFormatterMaleGender];
                  NSNumber *number = [NSNumber numberWithInteger:2];
                  NSLog(@"%@", [NSString stringWithFormat:NSLocalizedString(@"You came in %@ place!", nil), [ordinalNumberFormatter stringFromNumber:number]]);
                  

                  假设您为You come in %@ place!"提供了本地化字符串,输出将是:

                  Assuming you've provided localized strings for "You came in %@ place!", the output would be:

                  * English: "You came in 2nd place!"
                  * French: "Vous êtes venu à la 2eme place!"
                  * Spanish: "Usted llegó en 2.o lugar!"
                  

                  这篇关于Objective-C:将数字格式化为序数:1, 2, 3, .. to 1st, 2nd, 3rd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:无法使用 NdefFormatable 格式化 NFC 卡 下一篇:android.text.format.DateFormat 和 java.text.DateFormat 有什么

                  相关文章

                  最新文章

                  <small id='B1dZB'></small><noframes id='B1dZB'>

                    <legend id='B1dZB'><style id='B1dZB'><dir id='B1dZB'><q id='B1dZB'></q></dir></style></legend>
                    • <bdo id='B1dZB'></bdo><ul id='B1dZB'></ul>

                    1. <tfoot id='B1dZB'></tfoot>
                    2. <i id='B1dZB'><tr id='B1dZB'><dt id='B1dZB'><q id='B1dZB'><span id='B1dZB'><b id='B1dZB'><form id='B1dZB'><ins id='B1dZB'></ins><ul id='B1dZB'></ul><sub id='B1dZB'></sub></form><legend id='B1dZB'></legend><bdo id='B1dZB'><pre id='B1dZB'><center id='B1dZB'></center></pre></bdo></b><th id='B1dZB'></th></span></q></dt></tr></i><div id='B1dZB'><tfoot id='B1dZB'></tfoot><dl id='B1dZB'><fieldset id='B1dZB'></fieldset></dl></div>