11-23-2011, 02:13 PM
#1 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
reset a ViewController without quit the app...
can i reset a ViewController without quit the app
because i need to reset all data...
11-23-2011, 02:15 PM
#2 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
Create a reset method that sets all your data to 0, nil, whatever you need and call it when you need to reset.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.
New app - See screenshots and details at
www.globaclock.com .
If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
11-23-2011, 02:43 PM
#3 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
if i do this action too many times the app is crash:
Code:
int randomNumber = arc4random() % 10;
switch (randomNumber) {
break;
default:
break;
}
if after any time i reset the viewController is not crashing...
11-23-2011, 02:46 PM
#4 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
What is the purpose of that switch statement? And is this the whole method? Are you doing anything with randomNumber?
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.
New app - See screenshots and details at
www.globaclock.com .
If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
11-23-2011, 02:58 PM
#5 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
yes i use randomNumber... and when i using too many times my app is crash
11-23-2011, 02:59 PM
#6 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
What's the crash message? Also, you didn't answer my question about the switch statement.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.
New app - See screenshots and details at
www.globaclock.com .
If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
11-23-2011, 10:44 PM
#7 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
i dont know i found this code in other forum...
this code is not good ?
Last edited by jordanmeir; 11-23-2011 at 10:49 PM .
11-23-2011, 11:13 PM
#8 (permalink )
Reading the Documentation
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
Tat's just an empty switch. How do you expect us to tell you what's wrong? And how can you not know what the error is in the crash log, don' you see the Console?!
11-24-2011, 12:54 PM
#9 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
sometimes is crash when i do the randomNumber
and some times is crash when i click reset button (reset the nsstring to '0')
look on thus log:
Code:
randomNumber1
2011-11-24 20:53:08.851 app[32677:207] randomNumber2
2011-11-24 20:53:14.955 app[32677:207] randomNumber3
2011-11-24 20:53:22.367 app[32677:207] Reachability Flag Status: -R ------- networkStatusForFlags
2011-11-24 20:53:22.370 app[32677:207] ResetButton
2011-11-24 20:53:23.843 app[32677:207] randomNumber1
2011-11-24 20:53:27.836 app[32677:207] randomNumber2
2011-11-24 20:53:30.108 app[32677:207] randomNumber3
2011-11-24 20:53:38.693 app[32677:207] Reachability Flag Status: -R ------- networkStatusForFlags
sharedlibrary apply-load-rules all
Current language: auto; currently objective-c
it was crashed when i pushed the 'ResetButton'
what mean the last row ?
11-24-2011, 01:34 PM
#10 (permalink )
Reading the Documentation
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
Nothing important. Unless we see a crash log (which that wasn't) or the whole source for that method, we can't help you.
11-24-2011, 01:52 PM
#11 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
ok, can you give me an other randomNumber command ?
because i think this randomNumber is crashing
11-24-2011, 01:54 PM
#12 (permalink )
Reading the Documentation
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
It's not. The one you have is fine. Your problem is elsewhere.
11-24-2011, 02:42 PM
#13 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
after any crash he show my this:
Code:
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
11-24-2011, 02:49 PM
#14 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
Also not the problem. Like baja said, no crash log, no code, no help.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.
New app - See screenshots and details at
www.globaclock.com .
If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
11-24-2011, 02:53 PM
#15 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
so, thanks for everybody
i will find the crash code...
11-24-2011, 02:55 PM
#16 (permalink )
Just helping out.
Join Date: Feb 2011
Posts: 2,565
Just a tip, if you are using the latest Xcode, you need to activate the console to see crash messages. I believe the shortcut for that is command shift c.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.
New app - See screenshots and details at
www.globaclock.com .
If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
11-25-2011, 08:36 AM
#17 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
thanks...
but i found the crash error...
the error:
Code:
UIImage *img = [UIImage imageNamed:@"123.png"];
[Button setImage:img forState:UIControlStateNormal];
[img release];
the reset data action:
Code:
[Button setImage:nil forState:UIControlStateNormal];
it work but if i do this few times it crash
do you have an other way to chango the image/BG of button ??
11-25-2011, 11:11 AM
#18 (permalink )
Reading the Documentation
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
That's not the problem. The problem is that you are releasing an autoreleased object. imageNamed returns an autoreleased object which you should not explicitly release. I suggest you read the Memory Management Programming Guide from the documentation:
Loading
11-25-2011, 12:33 PM
#19 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
the crash bug was fix
i change the old code to this:
Code:
[button setBackgroundImage:[[UIImage imageNamed:@"123.png"] stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0] forState:UIControlStateNormal];
and is not crashing
11-25-2011, 02:40 PM
#20 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
can you give me an other randomNumber ?
because i when i press again it have a chance to show me the last "case" again.
and i don't want this...
I want him to show me that one time !
11-25-2011, 02:42 PM
#21 (permalink )
Reading the Documentation
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
That's what random generators do. It doesn't mean that each time you generate you'll get a number different from all the previously generated. If you want that, then you need to keep track of all the numbers and keep generating until you get one that hasn't been generated yet. Since you might be looking for a sequence of numbers (0-9) in random order, it might be more efficient to create an array with those numbers in it and shuffle the array.
11-25-2011, 03:42 PM
#22 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
can you give me an example how to do this ?
i have no idea
11-25-2011, 04:15 PM
#23 (permalink )
Reading the Documentation
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
Use an array, each time you generate a number loop through the array to see if that number is already in the array, if it isn't, add it to the array and use it, if it is, generate a new one and re-check.
11-25-2011, 04:29 PM
#24 (permalink )
Registered Member
Join Date: Dec 2010
Posts: 129
thanks i will try
Thread Tools
Display Modes
Linear Mode
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
» Advertisements
» Online Users: 401
14 members and 387 guests
7twenty7 , chiataytuday , Clouds , dedeys78 , Duncan C , e2applets , EvilElf , iekei , ipodphone , leostc , Murphy , QuantumDoja , sacha1996 , Sami Gh
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55