Loops/Foreach: Difference between revisions
Content added Content deleted
Langurmonkey (talk | contribs) |
(→{{header|Objective-C}}: conventional syntax) |
||
Line 2,187: | Line 2,187: | ||
{{works with|Cocoa}} |
{{works with|Cocoa}} |
||
<syntaxhighlight lang="objc">NSArray *collect; |
<syntaxhighlight lang="objc">NSArray *collect; |
||
//... |
// ... |
||
for(Type i in collect){ |
for (Type i in collect) { |
||
NSLog(@"%@", i); |
NSLog(@"%@", i); |
||
}</syntaxhighlight> |
}</syntaxhighlight> |
||
Line 2,196: | Line 2,196: | ||
{{works with|Objective-C|<2.0}} |
{{works with|Objective-C|<2.0}} |
||
<syntaxhighlight lang="objc">NSArray *collect; |
<syntaxhighlight lang="objc">NSArray *collect; |
||
//... |
// ... |
||
NSEnumerator *enm = [collect objectEnumerator]; |
NSEnumerator *enm = [collect objectEnumerator]; |
||
id i; |
id i; |
||
while |
while ((i = [enm nextObject])) { |
||
// do something with object i |
// do something with object i |
||
}</syntaxhighlight> |
}</syntaxhighlight> |