Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > loops in cocoa, please help !

loops in cocoa, please help !
Thread Tools
Addicted to MacNN
Join Date: Apr 2000
Status: Offline
Reply With Quote
May 5, 2001, 02:29 AM
 
how do you implement a for-loop or a while loop in cocoa ?, i cant seem to get any of them to work !
heres my code :

for(int i =0;i<100;i++)
{
}

it never works, how do i put that into a cocoa class(objective C)
Thanks.
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Virginia, US
Status: Offline
Reply With Quote
May 5, 2001, 03:17 AM
 
The same as in C.

int i;

for(i=0; i<100; i++)
{
}

In C (unlike C++ and Java), you have to declare your variables at the beginning of a block; declaring them inline like that is not supported.

The recent ANSI C99 spec does change the C language spec to allow declaring of inline variables (at least in for loops such as yours), but C99 compliance has not been integrated into Apple's cc yet. I'm sure it will get there eventually, but it's not there now.
     
Addicted to MacNN
Join Date: Apr 2000
Status: Offline
Reply With Quote
May 5, 2001, 11:40 AM
 
thaks for the feedback, i really appreciate it.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:57 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2