Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-23-2011, 02:13 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default reset a ViewController without quit the app...

can i reset a ViewController without quit the app
because i need to reset all data...
jordanmeir is offline   Reply With Quote
Old 11-23-2011, 02:15 PM   #2 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

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.
Domele is offline   Reply With Quote
Old 11-23-2011, 02:43 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default

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...
jordanmeir is offline   Reply With Quote
Old 11-23-2011, 02:46 PM   #4 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

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.
Domele is offline   Reply With Quote
Old 11-23-2011, 02:58 PM   #5 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default

yes i use randomNumber... and when i using too many times my app is crash
jordanmeir is offline   Reply With Quote
Old 11-23-2011, 02:59 PM   #6 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

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.
Domele is offline   Reply With Quote
Old 11-23-2011, 10:44 PM   #7 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default

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.
jordanmeir is offline   Reply With Quote
Old 11-23-2011, 11:13 PM   #8 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

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?!
baja_yu is offline   Reply With Quote
Old 11-24-2011, 12:54 PM   #9 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default

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 ?
jordanmeir is offline   Reply With Quote
Old 11-24-2011, 01:34 PM   #10 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Nothing important. Unless we see a crash log (which that wasn't) or the whole source for that method, we can't help you.
baja_yu is offline   Reply With Quote
Old 11-24-2011, 01:52 PM   #11 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default

ok, can you give me an other randomNumber command ?

because i think this randomNumber is crashing
jordanmeir is offline   Reply With Quote
Old 11-24-2011, 01:54 PM   #12 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

It's not. The one you have is fine. Your problem is elsewhere.
baja_yu is offline   Reply With Quote
Old 11-24-2011, 02:42 PM   #13 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default

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;
}
jordanmeir is offline   Reply With Quote
Old 11-24-2011, 02:49 PM   #14 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

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.
Domele is offline   Reply With Quote
Old 11-24-2011, 02:53 PM   #15 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default

so, thanks for everybody
i will find the crash code...
jordanmeir is offline   Reply With Quote
Old 11-24-2011, 02:55 PM   #16 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

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.
Domele is offline   Reply With Quote
Old 11-25-2011, 08:36 AM   #17 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default

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 ??
jordanmeir is offline   Reply With Quote
Old 11-25-2011, 11:11 AM   #18 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

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…
baja_yu is offline   Reply With Quote
Old 11-25-2011, 12:33 PM   #19 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default

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
jordanmeir is offline   Reply With Quote
Old 11-25-2011, 02:40 PM   #20 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default

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 !
jordanmeir is offline   Reply With Quote
Old 11-25-2011, 02:42 PM   #21 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

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.
baja_yu is offline   Reply With Quote
Old 11-25-2011, 03:42 PM   #22 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default

can you give me an example how to do this ?
i have no idea
jordanmeir is offline   Reply With Quote
Old 11-25-2011, 04:15 PM   #23 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

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.
baja_yu is offline   Reply With Quote
Old 11-25-2011, 04:29 PM   #24 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 129
jordanmeir is on a distinguished road
Default

thanks i will try
jordanmeir is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» 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
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:36 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0