Sanoj Kashyap Sanoj Kashyap - 1 month ago 7
Objective-C Question

Xcode 7.3: NSArray print custom objects as "" why?

I have array with custom type object when I tried to print it's shows me like array:

(
"",

"",
)


if I am accessing individual element it's show blank space even though printing property of element print correctly.why?

Updated:

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

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

"",

""



)


When I am iterating through it :

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 Sample[52679:1434653] Calendar -

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 -
Handball practice

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

Answer

The NSLog display of your class depends on your class's implementation of description. Your Calendar class has a description property whose value is an empty string.

Comments