iphone - Control flow in Objective-C -


I have been working through this book in the book:

  - ( Zero) Playensound {NSString * path = [[NSBundle main bundle] Pathfoser resource: @ "win" type: @ "Wave"]; SystemSoundID soundID; Audio ServicesSystemSystemsID ((CFRRRF) [NSR File URL Thither: Path], and Voice ID); AudioSyverSpeed ​​System Sound (sound id); WinLabel.text = @ "Win!"; [Self Performance Selector: Object with @Selecton: After Zero: 1.5]; } - Spin {IBAction} {BOOL win = NO; Int numInRow = 1; Int lastVal = -1; {Int newValue = random ()% [self.column1 count] for (int i = 0; i <5; i ++); If (NewValue == LastWell) numInRow ++; Else numInRow = 1; LastVal = newValue; [Picker Pick: New Value Component: i Animated: Yes]; [Reload beaker component: i]; If (numInRow> = 3) win = yes; } Button.hidden = Yes; NSString * path = [[NSBundle main bundle] Pathfoser resource: @ Type of "Defect": @ "Wave"]; SystemSoundID soundID; Audio ServicesSystemSystemsID ((CFRRRF) [NSR File URL Thither: Path], and Voice ID); AudioSyverSpeed ​​System Sound (sound id); If (win) [self display selector: object with @silver (play winesond): after zero: .5]; And [self display selector: @icollector (object): after zero: .5]; WinLabel.text = @ ""; }  

When you click the spin button it calls this spin method if the win is yes, then PlayWinSound is what changes the value of winLabel @ "Win! " Why is it that if Win is the result of a spin in the win, then the text in "Win!" In WinLabel And remains in that way should there not be a refund on the spin method which will convert winLabel to @ ""?

Yes, and does return to the spin method. The trick is in the call that is displaying the playwin.sound method:

Execution: .5];

Note the later section of the method. It sets the time for an invitation of playWinSound at the first available time after the passage of 0.5 seconds. Specifically, after 0.5 seconds have passed, the first run will be shown in the beginning of the loop. This method is already being called inside the running loop, so the playwind sound can not be executed after the return of the spin method.

He said, this is a very strange way of making the program structure. I think that they are determined to be winLabel.text to @ "" to make sure that it gets reset back to an empty string unless This particular @win! ", but I could have structured it very differently, nevertheless, that works.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -