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 01-21-2012, 08:37 PM   #1 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 4
Joey3140 is on a distinguished road
Default Use of undeclared identifier 'touchesBegan' HELP

We're having a problem with this block of code

---------------------------------------------------------------------------------------

- (void) touchesBeganNSSet *)touches withEventUIEvent *)event {
if (gameState == kStateRunning) {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (location.x < (self.view.bounds.size.width/2)) {
touchState = kLeftDown;
ballVelocity.x += 0.2;
}
else {
touchState = kRightDown;
ballVelocity.x +=0.2;
}
}
}

- (void)touchesEndedNSSet *)touches withEventUIEvent *)event {
touchState = kTOuchesEnded

---------------------------------------------------------------------------------------

The error "Use of undeclared identifier 'touchesBegan' " occurs on the red line. Theres nothing in the TGWViewController.h that talks about 'touchesBegan' and we're not sure if there should be. Help please
Joey3140 is offline   Reply With Quote
Old 01-21-2012, 08:42 PM   #2 (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

What's the TGWViewController? Subclass of UIViewController?
baja_yu is offline   Reply With Quote
Old 01-21-2012, 08:46 PM   #3 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 4
Joey3140 is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
What's the TGWViewController? Subclass of UIViewController?
Yes its a subclass of my UIViewController
Joey3140 is offline   Reply With Quote
Old 01-21-2012, 10:04 PM   #4 (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 method is part of UIResponder from which UIViewController inherits. The definition looks fine so the problem could be somewhere else. Scan your code, particularly code before this method for syntax errors, maybe a missing bracket or semicolon. The IDE doesn't always mark the exact location of the problem.
baja_yu is offline   Reply With Quote
Old 01-21-2012, 10:16 PM   #5 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 4
Joey3140 is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
That method is part of UIResponder from which UIViewController inherits. The definition looks fine so the problem could be somewhere else. Scan your code, particularly code before this method for syntax errors, maybe a missing bracket or semicolon. The IDE doesn't always mark the exact location of the problem.
must i scan the code manually? or is there an easier way?
Joey3140 is offline   Reply With Quote
Old 01-21-2012, 11:44 PM   #6 (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

When the IDE fails, yes, but in those cases the error is usually just above. Try commenting out the method just before it and see if the situation changes. If it does, the problem is in that method.
baja_yu is offline   Reply With Quote
Old 01-22-2012, 09:11 AM   #7 (permalink)
Registered Member
 
Join Date: Jun 2009
Location: Ypsilanti, Michigan
Age: 63
Posts: 1,549
RLScott is on a distinguished road
Default

I second the suggestion from baja_yu that the problem may be from a missing bracket in the code above this point. If all brackets were matched before this point then it would be perfectly fine to begin the definition of a method at this point. Even if you misspelled the method name or got the parameters wrong, that would not produce the error you got. The error you reported is what happens when the compiler thinks you are still inside the previous method and that any identifier encountered must necessarily refer to something that was already defined. So I think it is very likely that brackets do not match. Use the IDE to find the matching brackets to the previous method and see if they are where you expected them to be.
RLScott is offline   Reply With Quote
Reply

Bookmarks

Tags
app, basic, error

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: 394
10 members and 384 guests
7twenty7, Atatator, FrankWeller, glenn_sayers, guusleijsten, iphonedevshani, MAMN84, QuantumDoja, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

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