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 12-05-2010, 02:04 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2009
Location: Wien/Austria
Posts: 242
StefanL is on a distinguished road
Default Timer inside a (BOOL) Method?

Hi Folks,

I am checking the state of a button (selected/unselected) inside a "BOOL - Methode" like this:

Code:
if (_curHighlighted) {

			if (selectedItem != curSelection) {

				if ([self.selectedWinzis count] == 2) {

					//[self schedule: @selector(unselect:) interval:1.0];

					selectedItem = [self.selectedWinzis objectAtIndex:1];
					[selectedItem unselected];

					selectedItem = [self.selectedWinzis objectAtIndex:0];
					[selectedItem unselected];

					[self.selectedWinzis removeObjectAtIndex:1];
					[self.selectedWinzis removeObjectAtIndex:0];

				}
			state = kMenuStateTrackingTouch;
			return YES;

			}
    }
    return NO;
My goal is to unselect after 1 second. But this has to happen inside the code above. Does anyone can forward me
into the correct direction?

Thanks for your support!

Br,

Stefan

Complete Methode:

Code:
-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {

    if ( state != kMenuStateWaiting ) return NO;

    curSelection = [self itemForTouch:touch];
    [curSelection selected];
    _curHighlighted = curSelection;

	[self.selectedWinzis addObject:curSelection];

	NSLog(@"CurArray: %@", self.selectedWinzis);

    if (_curHighlighted) {

			if (selectedItem != curSelection) {

				if ([self.selectedWinzis count] == 2) {

					//[self schedule: @selector(unselect:) interval:1.0];

					selectedItem = [self.selectedWinzis objectAtIndex:1];
					[selectedItem unselected];

					selectedItem = [self.selectedWinzis objectAtIndex:0];
					[selectedItem unselected];

					[self.selectedWinzis removeObjectAtIndex:1];
					[self.selectedWinzis removeObjectAtIndex:0];

				}
			state = kMenuStateTrackingTouch;
			return YES;

			}
    }
    return NO;

}
StefanL is offline   Reply With Quote
Old 12-05-2010, 02:24 PM   #2 (permalink)
Beast Mode
 
Join Date: Dec 2008
Age: 21
Posts: 1,971
Bertrand21 is on a distinguished road
Default

I'm not sure the full method name but that is why we have Xcode to finish typing our methods..

Code:
[self performSelector:@selector(unselect:) withObject:nil afterDelay:1.0];
__________________
Haters gonna Hate
Likers gonna Like
Bertrand21 is offline   Reply With Quote
Old 12-05-2010, 02:33 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2009
Location: Wien/Austria
Posts: 242
StefanL is on a distinguished road
Default

Quote:
Originally Posted by Bertrand21 View Post
I'm not sure the full method name but that is why we have Xcode to finish typing our methods..

Code:
[self performSelector:@selector(unselect:) withObject:nil afterDelay:1.0];
Hi Bertrand,

thanks for your feedback! The syntax is correct as I am using cocos2d - the problem occours, when I am using CCTimer like NSTimer, then the Return will not be called...

BR,

Stefan
StefanL is offline   Reply With Quote
Old 12-05-2010, 02:38 PM   #4 (permalink)
Beast Mode
 
Join Date: Dec 2008
Age: 21
Posts: 1,971
Bertrand21 is on a distinguished road
Default

Quote:
Originally Posted by StefanL View Post
Hi Bertrand,

thanks for your feedback! The syntax is correct as I am using cocos2d - the problem occours, when I am using CCTimer like NSTimer, then the Return will not be called...

BR,

Stefan
Where is the timer? Your method should return just fine... I'm not sure I understand. Did you put breakpoints to see if it is even hitting any of your returns...?
__________________
Haters gonna Hate
Likers gonna Like
Bertrand21 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: 388
7 members and 381 guests
chemistry, daudrizek, HemiMG, jeroenkeij, whitey99
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,665
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, daudrizek
Powered by vBadvanced CMPS v3.1.0

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