Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Lots of Button Events: crash and 'NSRangeException'

$
0
0

Hi Everyone,

I've got this strange crash bug that seems to occur when tapping on a lot of buttons on the screen. I've got about 10 buttons that all have event handlers on them. I show/hide the buttons on/off states, and also remove/add an AppProperty on each tap. The faster I tap the buttons, the sooner I get the crash and this message in the console: 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 27 beyond bounds [0 .. 25]'

var waterButtonNone = Titanium.UI.createButton({
                                backgroundImage: "../images/none.png", 
                                height:21,
                                width:74,
                                top: 197,
                                right:45,
                                zindex:2,
                            });
 
                            scrollView.add(waterButtonNone);
                            var setWaterStatus = "1";
                            Titanium.App.Properties.setString("waterStatus", setWaterStatus);
 
                            var waterButtonSeasonal = Titanium.UI.createButton({
                                backgroundImage: "../images/seasonal.png", 
                                height:19,
                                width:127,
                                top: 199,
                                right:18,
                                zindex:2,
                            });
 
                            var waterButtonYearRound = Titanium.UI.createButton({
                                backgroundImage: "../images/yearround.png", 
                                height:39,
                                width:75,
                                top: 192,
                                right:44,
                                zindex:2,
                            });
 
                            waterButtonNone.addEventListener('click',function()
                            {
                                waterButtonNone.hide();
                                scrollView.add(waterButtonSeasonal);
                                waterButtonSeasonal.show();
                                setWaterStatus = "2";
                                Titanium.App.Properties.removeProperty("waterStatus");
                                Titanium.App.Properties.setString("waterStatus", setWaterStatus);
                            });
 
                            waterButtonSeasonal.addEventListener('click',function()
                            {
                                waterButtonSeasonal.hide();
                                scrollView.add(waterButtonYearRound);
                                waterButtonYearRound.show();
                                setWaterStatus = "3";
                                Titanium.App.Properties.removeProperty("waterStatus");
                                Titanium.App.Properties.setString("waterStatus", setWaterStatus);
                            });
 
                            waterButtonYearRound.addEventListener('click',function()
                            {
                                waterButtonYearRound.hide();
                                waterButtonNone.show();
                                setWaterStatus = "1";
                                Titanium.App.Properties.removeProperty("waterStatus");
                                Titanium.App.Properties.setString("waterStatus", setWaterStatus);
                            });

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>