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 04-04-2011, 03:32 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2010
Location: Dubrovnik, Croatia
Posts: 22
tosibamaniac is on a distinguished road
Default Threads and voids

So here is the situation, I have a void that returns a bool and I MUST stop for 3 seconds before returning it and I can't sleep the main thread. Any help would be appreciated. Thank you in advance.

Last edited by tosibamaniac; 04-04-2011 at 04:17 PM.
tosibamaniac is offline   Reply With Quote
Old 04-04-2011, 03:40 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 70
creyon is on a distinguished road
Default

Can you give more details please?

Also void that returns a bool sounds a bit weird.
creyon is offline   Reply With Quote
Old 04-04-2011, 03:43 PM   #3 (permalink)
Registered Member
 
Join Date: Mar 2010
Location: Dubrovnik, Croatia
Posts: 22
tosibamaniac is on a distinguished road
Default

Sorry for that my english is not that good .
Code:
- (BOOL)animatingNavBar { 
// [...]
// Need to stop for 3 s here.
return YES;
}
tosibamaniac is offline   Reply With Quote
Old 04-04-2011, 04:01 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 70
creyon is on a distinguished road
Default

you could use

[self performSelector:<#(SEL)aSelector#> withObject:<#(id)anArgument#> afterDelay:<#(NSTimeInterval)delay#>];

you'll need to set up some new things:

- your animatingNavBar method will not be able to return anything now because of the delay thing. Instead it will call a new method after a 3s delay which will return a BOOL.

- Your new method can't return a bool just like that because the rest of the app doesn't know when it will be called (because of the delay) so it'll be better to post your bool result with a NSNotification or you can call it directly like this:

[self performSelector:@selector(methodThatUsesMyBool withObject:myBool afterDelay:3.0f];
creyon is offline   Reply With Quote
Old 04-04-2011, 04:17 PM   #5 (permalink)
Registered Member
 
Join Date: Mar 2010
Location: Dubrovnik, Croatia
Posts: 22
tosibamaniac is on a distinguished road
Default

Figured it out, thank you .
tosibamaniac is offline   Reply With Quote
Reply

Bookmarks

Tags
animation, bool, sleep(), thread

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: 366
12 members and 354 guests
condor304, dansparrow, dre, ilmman, LezB44, michelle, Objective Zero, samdanielblr, Sami Gh, shagor012, thephotographer, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

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