Xcode 7.3:NSArray将自定义对象打印为""为什么?

时间:2016-10-14 10:55:10

标签: ios objective-c xcode nsarray xcode7.3

当我尝试打印时,我有自定义类型对象的数组' s显示我像数组:

 (
    "",

    "",
 )

如果我正在访问单个元素,即使正确打印元素打印属性,它也会显示空白。为什么?

更新:

NSLog(@"%@",[[EventStore sharedEventStore] calendars]);

result - 2016-10-14 16:10:15.090 Sample[46141:431203] (

    "",

    ""



)

当我迭代它时:

        for (Calendar *c in [[EventStore sharedEventStore] calendars]) {

            NSLog(@"Calendar - %@",c);

            NSLog(@"Calendar tille - %@",c.title);

            NSLog(@"Calendar color - %@",c.color);

        }
  

2016-10-14 16:04:48.879样本[52679:1434653]日历 -

     

2016-10-14 16:04:56.221 Sample [52679:1434653] Calendar tille -   amanda@dev.com

     

2016-10-14 16:04:58.029 Sample [52679:1434653] Calendar color - (null)

     

2016-10-14 16:05:01.683 Sample [52679:1434653] Calendar -

     

2016-10-14 16:08:29.103 Sample [52679:1434653] Calendar tille -   手球练习

     

2016-10-14 16:08:29.637 Sample [52679:1434653] Calendar color - (null)

1 个答案:

答案 0 :(得分:2)

您班级的NSLog显示取决于您班级description的实施情况。您的Calendar类具有description属性,其值为空字符串。