KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
It seems from experimentation that the collection expression is evaluated only once. Consider this example: static NSArray *a; - (NSArray *)fcn { if (a == nil) a = [NSArray arrayWithObjects:@"one", @"two", @"three", nil]; NSLog(@"called"); return a; } ... for (NSString *s in [self fcn]) NSLog(@"%@", s); The output is: 2010-10-07 07:37:31.419 WidePhotoViewer Lite[23694:207] called 2010-10-07 07:37:31.420 WidePhotoViewer Lite[23694:207] one 2010-10-07 07:37:31.425 WidePhotoViewer Lite[23694:207] two 2010-10-07 07:37:31.425 WidePhotoViewer Lite[23694:207] three indicating that [self fcn] is called only once. Can anyone confirm that this is the specified (as opposed to merely observed) behavior? What I have in mind is doing something like this: for (UIView *v in [innerView subviews]) { instead of this: NSArray *vs = [innerView subviews]; for (UIView *v in vs) { Thoughts?
Tags (comma-separated)
Save Edits
Cancel