• <small id='1cp9X'></small><noframes id='1cp9X'>

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

    1. <legend id='1cp9X'><style id='1cp9X'><dir id='1cp9X'><q id='1cp9X'></q></dir></style></legend>
    2. <tfoot id='1cp9X'></tfoot>
        <bdo id='1cp9X'></bdo><ul id='1cp9X'></ul>

        从 NSArray 获取单个属性的 NSArray

        时间:2023-10-23
      1. <small id='kvDeu'></small><noframes id='kvDeu'>

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

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

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

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

                    <tbody id='kvDeu'></tbody>
                • 本文介绍了从 NSArray 获取单个属性的 NSArray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正面临一个非常常规的场景.

                  I am facing a very regular scenario.

                  我有一个 NSArray,它有一个自定义类型的对象,比如 Person.Person 类具有以下属性:firstName、lastName 和 age.

                  I have an NSArray which has object of a custom type, say Person. The Person class has the attributes: firstName, lastName and age.

                  如何从具有 Person 对象的 NSArray 中获取仅包含一个属性的 NSArray?

                  How can I get an NSArray containing only one attribute from the NSArray having Person objects?

                  类似:

                  NSArray *people;
                  NSArray *firstNames = [people getArrayOfAttribute:@"firstName" andType:Person.Class]
                  

                  我有一个解决方案,可以编写一个 for 循环并填写 firstNames 数组,但我不想这样做.

                  I have a solution of writing a for loop and fill in the firstNames array but I don't want to do that.

                  推荐答案

                  NSArray 将使用 KVC 为您处理此问题

                  NSArray will handle this for you using KVC

                  NSArray *people ...;
                  NSArray *firstName = [people valueForKey:@"firstName"];
                  

                  这将为您提供数组中每个条目的 firstName 值的数组

                  This will give you an array of the firstName values from each entry in the array

                  这篇关于从 NSArray 获取单个属性的 NSArray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:ImageIO:&lt;错误&gt;JPEG 损坏的 JPEG 数据:iphone 数据段过早结束 - 下一篇:EAAccessory/EASession 在后台拆除

                  相关文章

                  1. <small id='g8VN1'></small><noframes id='g8VN1'>

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

                    <tfoot id='g8VN1'></tfoot>

                  3. <legend id='g8VN1'><style id='g8VN1'><dir id='g8VN1'><q id='g8VN1'></q></dir></style></legend>

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