Activating UIAlertView = EXC_BAD_ACCESS ?

Discussion in 'iOS Development' started by iPodTouchDev, Jun 30, 2009.

  1. iPodTouchDev

    iPodTouchDev New Member

    Joined:
    Jan 18, 2009
    Messages:
    74
    Likes Received:
    0
    Device:
    iPod touch
    Ok, so I have a UIProgressView, and when I do:

    Code:
    progressView.progress = progressView.progress + 0.1;
    	if (progressView.progress == 1.0)
    {
              //adding + activating UIAlertView
    }
    The progressView reaches 1.0, but then the app crashes when the alertview is supposed to show.

    Any ideas?
    ------------------double post merged------------------
    Nevermind, solved!

    EDIT: Ok, solved it, but there's another problem. For the progressView to fill you have to have it repeat:
    Code:
    progressView.progress = progressView.progress + 0.1;
    over, and over. So anything I add to that function, will get repeated, over, and over.

    So if I do:

    Code:
    - (void)startTimer {
    	progressView.progress = progressView.progress + 0.1;
    	if (progressView.progress == 1.0)
    	{
    		Code for creating + activating the UIAlertView
    	}
    }
    The UIAlertView will show up, dismiss, show up, dismiss, etc.

    Any ideas?
  2. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Invalidate the timer when you show the alert.
  3. Ezekeel

    Ezekeel New Member

    Joined:
    Mar 15, 2009
    Messages:
    771
    Likes Received:
    0
    Device:
    iPhone 3GS (Black)
    Due to round-off errors when using floating point numbers with finite accuracy, the value will never be exactly equal to 1.0. Either you use an integer number as a counter which would be the cleanest way to implement this or you account for the inaccuracy of floating point number by changing the comparison to >= or you check for fabs(value - 1.0) <= epsilon where epsilon is a small number.

Share This Page