I have an entity schedule.
This schedule has some attributes like name, startdate, enddate, etc.
It also has a one to many relationship to times.
Times is an entity with only one attribute ‘time’ of the NSDate type.
So each schedule can have one or more times.
My previous implementation was an NSArray that I transformed into NSData for storage inside the schedule entity. I didn’t like that.
Now schedule.times gives an NSSet with Time entities.
So when I want a for loop I need to do:
for(Time *time in schedule.times) {
NSLog("%@", time.time);
}
My question: is there no way I can set it up so that I can just do the following?
for(Time *time in schedule.times) {
NSLog("%@", time);
}
Well, for the specific simple case you’ve asked about, you can simply implement a
-descriptionmethod on theTimeclass to returnself.time.description.When you format an object into a string using the
%@format specifier, it simply asks the object for its description and prints the resulting string.However, I suspect that your simple case is misleading because you don’t really care about logging the object. What do you really care about?