objective c - Confounding Cocoa problem — program hangs unless there’s an unrecognised method call -


Stay with me, it's hard to explain. I hope some heroes from there will know what is going on here, some history is needed;

One of my coca objects, "ball" represents a small graphic. It is understood only within one scene. In some of the ball's methods, it asks the scene to Radra, the most important thing It is that whenever the position of the ball is set to the ball, it asks to see the redraw. It is achieved in setter.

This is the mouth, as suggested in the suggestion:

M

  - (zero) mouseup: (nse *) event {if (! [Runner is empty]) [[walkpath removeAllPoints]; [Voilepath append bisier path: runner path]; [Remove runner] all points; [[Organizing yourself] Setup: 0]; [[Self-organizing] Setpath: Voyalpath]; [Nstimer scheduled timer with interval: .01 target: [self-organized] selector: @sillector (speed) user information: zero repeats: yes]; }}  

In the ball. M

  - (zero) speed {CGFloat juice = 10; BOOL loop = yes; While (loop) {if ([self-step] == [[self path] element)] {if ([[self timer], wild]] {[self timer] is invalid;; [[self path] removed All points]; // @ throw ([NSE exception exception: with name: @ "test" reason: @ "reason" user information: zero]);} if (loop) {CGFloat distance; NSPoint steppoint; if ([[self Path] element] number]> gt; {NSPoint return points [2]; [[Self path] Elementindex: [Self-step] Connected points: returnpoints] Steppoint = return points [0]; distance = pixeldist Ions ([self-space], steppoint);} if (distance and lieutenant; = juice) {[self-setpoint: steppoint]; if (distance & lt; juice) {juice - = distance; loop = yes; [self setstep: Self step] +1];} Else {loop = NO;}} and {NSPoint cut point = move battein ([self location], steppoint, juice); [self setposition: cutpoint]; loop = no;}}}} }  

Can you also tell how you manage exceptions? Generally an unfamiliar selector is your The program will end the program. You may need an exception instead of an unrecognized selector:

  @throw ([NSException exception: with: @ "test" reason: @ "cause" userInfo : Zero]);  

If this also fixes, then you are doing something after this code that freezes the app.

Edit: Thanks Code Update

Here's some strange stuff going on! I am not going to write the whole thing again, so here are some pointers:

  • First of all: You are looping inside some routine, which is called timer loop. Is it intended? There is no way to stop execution within that code, while () loop, then it will be in any blink anyway. You will need to keep some state information in the class as if a loop counter is called speed each time.
  • Second: If you start a timer, it will call your selector as an argument with the timer. Therefore define the function as - (zero) speed: (NSTimer *) timer , and use timer , not [self timer] (Your next timer will not be anyway, if you do not specify it!)
  • Third: You're firing 100 times in a second, this is a lot, and maybe someone Even more than the refresh rate of the device you are writing for it, I think 20 / sec is enough. Fourth: To make sure, if you change it to - (zero) speed: (NSTimer *) timer , do not forget @selector (speed: ) (do not forget : )

Fix them things, and if it still If broken, please update your question again and comment so that we can know. Good luck!


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -