4
I’m trying to run a loop
in the Xcode, but it doesn’t work.
On the console gets:
Type the loop number:
5
Nothing else happens in the terminal. 0,1,2,3,4,5 does not appear.
In short, it stands still after I type any number, however, from what I saw, it is still running, I have to give a stop to be able to run again.
The debug Session:
I put a breakpoint in the variables and gave a stepover
This has to do with @autoreleasepool
? Same goes for mine switch
.
My code
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]){
@autoreleasepool {
int i, usuario;
NSLog(@"Digite o numero do loop: ");
scanf("%i", &usuario);
for (i=0; i<=usuario; i++) {
NSLog(@"%i", i);
}
}
return 0;
}
The project was created in Foundation, Command Line Tool.
Added some more information.
– Lucas Castellani
I added what was missing.
– Lucas Castellani
When the Debugger is stopped on the line
scanf()
, press F6 (Step Over). At this time, thescanf()
is executed and you must enter a number followed by the Return key. After that, the Debugger must move to the next line, the one containing thefor
. In your case, what exactly occurs in each of these steps?– user7835
Well, the Debugger is marked on the scanf line, with a (lldb) at the end of the console, when I press F6, the line that marks the Debugger is gone, as well as the (lldb), so I type any number and give enter, but nothing else happens, it seems that it doesn’t even enter the for...
– Lucas Castellani