hi guys,
set 'for' statement loop 10 times i'm not getting 10 loops. returns 6, @ times returns 4,3,7 etc. did 10 return during runtime.
i've attached screenshot of output along.code:int y_axis = 200; (int q = 0; q < 10; q++) { int rand = arc4random()%10; if (rand == 0) { nsstring *msg = @"i've got 0"; uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(0, y_axis, 320, 21)]; label.text = msg; [scrollview addsubview:label]; [label release]; [msg release]; y_axis = y_axis + 20; } if (rand == 1) { nsstring *msg = @"i've got 1"; uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(0, y_axis, 320, 21)]; label.text = msg; [scrollview addsubview:label]; [label release]; [msg release]; y_axis = y_axis + 20; } if (rand == 2) { nsstring *msg = @"i've got 2"; uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(0, y_axis, 320, 21)]; label.text = msg; [scrollview addsubview:label]; [label release]; [msg release]; y_axis = y_axis + 20; } if (rand == 3) { nsstring *msg = @"i've got 3"; uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(0, y_axis, 320, 21)]; label.text = msg; [scrollview addsubview:label]; [label release]; [msg release]; y_axis = y_axis + 20; } if (rand == 4) { nsstring *msg = @"i've got 4"; uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(0, y_axis, 320, 21)]; label.text = msg; [scrollview addsubview:label]; [label release]; [msg release]; y_axis = y_axis + 20; } }
thanx in advance...
attached files:
hmm bit puzzling.
changing "q < 10" q =< 10 work.
switch case statement more suitable here?
have never done obj c programming, sorry can't of more help.
Forums iPhone, iPad, and iPod Touch iOS Programming
- iPhone
- Mac OS & System Software
- iPad
- Apple Watch
- Notebooks
- iTunes
- Apple ID
- iCloud
- Desktop Computers
- Apple Music
- Professional Applications
- iPod
- iWork
- Apple TV
- iLife
- Wireless
No comments:
Post a Comment