error: synax error before '{' token

Posts 1–15 of 33 · Page 1 of 3
error: synax error before '{' token
Im coding a calculator app using Iphone SDK and im having trouble.
Every time i click the build and go button i get "error: synax error before '{' token"
here is a pic



Any idea on what i should do.
here is the coding

Code:
#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
    return NSApplicationMain(argc,  (const char **) argv);
}

#import "UberCalculatorController.h"
#import "UberCalculator_prefix.pch.h"

@implementation MasterView

- (id) initWithFrame: (CGRect) frame {
	//NSLog(@"MasterView initWithFrame");

	self = [super initWithFrame: frame];
	views = [[NSMutableArray alloc] init];
	currentViewIndex = -1;
	
	return self;
}

- (BOOL) canHandleSwipes {
	return TRUE;
}

- (int)swipe:(int)type withEvent:(struct __GSEvent *)event {
	//NSLog(@"MasterView swipe: %d withEvent: %@", type, event);
	int transType = 0;
	
	if (type == 4) {		// kUIViewSwipeLeft
		transType = 1;
		currentViewIndex--;
		if (currentViewIndex < 0) {
			currentViewIndex = [views count] - 1;
		}
	} else if (type == 8) {	//kUIViewSwipeRight
		transType = 2;
		currentViewIndex++;
		if (currentViewIndex == [views count]) {
			currentViewIndex = 0;
		}
	}

	//NSLog(@"transition to view %d", currentViewIndex);
	if (transType != 0) {
		[self transition:transType toView: [views objectAtIndex: currentViewIndex]];	
	}
	
	// transition to current view
    return [ super swipe:type withEvent:event ];
}

- (void) addView: (id) fp8 {
	[views addObject: fp8];	
	if (currentViewIndex == -1) {
		[super addSubview: fp8];
		currentViewIndex = 0;
	}
}

- (void) dealloc {
	[views release];
	[super dealloc];
}
@end

@implementation CalculatorApp

- (void) handleCommand: (NSString *) command {
	//NSLog(@"CalculatorApp handleCommand: [%@]", command);
	
	// pass the commands down the chain
	[engine sendCommand: command];

	// then update all the views...
	[self updateViews];
}

- (void) updateViews {

	[basicCalculatorView updateView];
}

/- (void) applicationDidFinishLaunching: (id) fp8 {

	engine = [[CalculatorEngine alloc] init];


	struct CGRect frame = [UIHardware fullScreenApplicationContentRect];
	frame.origin.x = frame.origin.y = 0.0f;
	mainWindow = [[UIWindow alloc] initWithContentRect: frame];

	masterView = [[MasterView alloc] initWithFrame: frame];

	
	basicCalculatorView = [[BasicCalculatorView alloc] initWithFrame: frame withController: self withEngine: engine withType: 0];
	[masterView addView: basicCalculatorView];
	
	sciCalculatorView = [[BasicCalculatorView alloc] initWithFrame: frame withController: self withEngine: engine withType: 1];
	[masterView addView: sciCalculatorView];

	
	navView = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 48.0f)];
	[navView showButtonsWithLeftTitle: @"Decimal" rightTitle: @"Hex" leftBack: YES];
	[navView setPrompt: @"Caclulator2"];
	[navView setBarStyle: 0];
	[navView enableAnimation];
	//[masterView addView: navView];

	diagView = [[UITouchDiagnosticsLayer alloc] initWithFrame: frame];
	[diagView setDisplayChargeMap: true];
	[diagView setDisplayHitRects: true];
	[diagView setDisplayTouchEvents: true];
	[diagView setTrackTouchEvents: true];
	//[masterView addView: diagView];
	

	[mainWindow orderFront: self];
    [mainWindow makeKey: self];
	[mainWindow _setHidden: NO];	
	[mainWindow setContentView: masterView]; 
}

- (void)acceleratedInX:(float)xx Y:(float)yy Z:(float)zz {
	NSLog(@"accelerated x=%g, y=%g, z=%g", xx, yy, zz);
}

@end
Hell_Demon: added code tags for easier reading.
You are missing an } somewhere. Why don't you try and double click the error, and then tell me what line its on. I know how to iPhone code so, yea
Meh, use [code] Tags, and you should have said that it is Objective-C

@serpentine
nop, in there he is closing:

Code:
- (int)swipe:(int)type withEvent:(struct __GSEvent *)event {
plus thats quite obvious, if he doing a return
Quote Originally Posted by 'Bruno View Post
Meh, use [code] Tags, and you should have said that it is Objective-C

@serpentine
nop, in there he is closing:

Code:
- (int)swipe:(int)type withEvent:(struct __GSEvent *)event {
plus thats quite obvious, if he doing a return
iPhone language is Objective C. I'm looking at the screeny hold on friend
Quote Originally Posted by frozenasasin View Post
// transition to current view
return [ super swipe:type withEvent:event ];
}
Should be:
Code:
// transition to current view
return [ super swipe:type withEvent:event ];
I can't read that orange text. o.O

EDIT: Aha! I found it... I think!
Quote Originally Posted by frozenasasin View Post
- (int)swipe:(int)type withEvent:(struct __GSEvent *)event {
//NSLog(@"MasterView swipe: %d withEvent: %@", type, event);
int transType = 0;

if (type == 4) { // kUIViewSwipeLeft
transType = 1;
currentViewIndex--;
if (currentViewIndex < 0) {
currentViewIndex = [views count] - 1;
}
} else if (type == 8) { //kUIViewSwipeRight
transType = 2;
currentViewIndex++;
if (currentViewIndex == [views count]) {
currentViewIndex = 0;
}
}
Should be:
Code:
- (int)swipe:(int)type withEvent:(struct __GSEvent *)event {
//NSLog(@"MasterView swipe: %d withEvent: %@", type, event);
int transType = 0;

if (type == 4) { // kUIViewSwipeLeft
transType = 1;
currentViewIndex--;
if (currentViewIndex < 0) {
currentViewIndex = [views count] - 1;
}
} else if (type == 8) { //kUIViewSwipeRight
transType = 2;
currentViewIndex++;
if (currentViewIndex == [views count]) {
currentViewIndex = 0;
}
kk ive been trying to find a solution for an hour... i googled it. i yahooed it. i binged it.
but nothing that helped
Quote Originally Posted by frozenasasin View Post
kk ive been trying to find a solution for an hour... i googled it. i yahooed it. i binged it.
but nothing that helped
Patience. I'm not the greatest iPhone programming so hold on I need to test
Code:
#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
	return NSApplicationMain(argc, (const char **) argv);
}

#import "UberCalculatorController.h"
#import "UberCalculator_prefix.pch.h"

@implementation MasterView

- (id) initWithFrame: (CGRect) frame 
{
	//NSLog(@"MasterView initWithFrame");

	self = [super initWithFrame: frame];
	views = [[NSMutableArray alloc] init];
	currentViewIndex = -1;

	return self;
}

- (BOOL) canHandleSwipes 
{
	return TRUE;
}

- (int)swipe:(int)type withEvent:(struct __GSEvent *)event 
{
	//NSLog(@"MasterView swipe: %d withEvent: %@", type, event);
	int transType = 0;

	if (type == 4) 
	{ 
	// kUIViewSwipeLeft
	transType = 1;
	currentViewIndex--;
		if (currentViewIndex < 0) 
		{
			currentViewIndex = [views count] - 1;
		}
	} 
	else if (type == 8) 
	{ 
	//kUIViewSwipeRight
		transType = 2;
		currentViewIndex++;

		if (currentViewIndex == [views count]) 
		{
			currentViewIndex = 0;
		}
	}

	//NSLog(@"transition to view %d", currentViewIndex);
	if (transType != 0) 
	{
		[self transition:transType toView: [views objectAtIndex: currentViewIndex]]; 
	}

	// transition to current view
	return [ super swipe:type withEvent:event ];
}

- (void) addView: (id) fp8 
{
	[views addObject: fp8]; 
	if (currentViewIndex == -1) 
	{
		[super addSubview: fp8];
		currentViewIndex = 0;
	}
}

- (void) dealloc 
{
	[views release];
	[super dealloc];
}
@end

@implementation CalculatorApp

- (void) handleCommand: (NSString *) command
{
	//NSLog(@"CalculatorApp handleCommand: [%@]", command);

	// pass the commands down the chain
	[engine sendCommand: command];

	// then update all the views...
	[self updateViews];
}

- (void) updateViews 
{
	[basicCalculatorView updateView];
}

- (void) applicationDidFinishLaunching: (id) fp8 
{
	engine = [[CalculatorEngine alloc] init];


	struct CGRect frame = [UIHardware fullScreenApplicationContentRect];
	frame.origin.x = frame.origin.y = 0.0f;
	mainWindow = [[UIWindow alloc] initWithContentRect: frame];

	masterView = [[MasterView alloc] initWithFrame: frame];


	basicCalculatorView = [[BasicCalculatorView alloc] initWithFrame: frame withController: self withEngine: engine withType: 0];
	[masterView addView: basicCalculatorView];

	sciCalculatorView = [[BasicCalculatorView alloc] initWithFrame: frame withController: self withEngine: engine withType: 1];
	[masterView addView: sciCalculatorView];


	navView = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 48.0f)];
	[navView showButtonsWithLeftTitle: @"Decimal" rightTitle: @"Hex" leftBack: YES];
	[navView setPrompt: @"Caclulator2"];
	[navView setBarStyle: 0];
	[navView enableAnimation];
	//[masterView addView: navView];

	diagView = [[UITouchDiagnosticsLayer alloc] initWithFrame: frame];
	[diagView setDisplayChargeMap: true];
	[diagView setDisplayHitRects: true];
	[diagView setDisplayTouchEvents: true];
	[diagView setTrackTouchEvents: true];
	//[masterView addView: diagView];


	[mainWindow orderFront: self];
	[mainWindow makeKey: self];
	[mainWindow _setHidden: NO]; 
	[mainWindow setContentView: masterView]; 
}

- (void)acceleratedInX:(float)xx Y:(float)yy Z:(float)zz 
{
	NSLog(@"accelerated x=%g, y=%g, z=%g", xx, yy, zz);
}

@end
looks better
wait u have a mac? MAC BUDDY!
Found it, check my edited post!
Quote Originally Posted by 'Bruno View Post
Code:
#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
	return NSApplicationMain(argc, (const char **) argv);
}

#import "UberCalculatorController.h"
#import "UberCalculator_prefix.pch.h"

@implementation MasterView

- (id) initWithFrame: (CGRect) frame 
{
	//NSLog(@"MasterView initWithFrame");

	self = [super initWithFrame: frame];
	views = [[NSMutableArray alloc] init];
	currentViewIndex = -1;

	return self;
}

- (BOOL) canHandleSwipes 
{
	return TRUE;
}

- (int)swipe:(int)type withEvent:(struct __GSEvent *)event 
{
	//NSLog(@"MasterView swipe: %d withEvent: %@", type, event);
	int transType = 0;

	if (type == 4) 
	{ 
	// kUIViewSwipeLeft
	transType = 1;
	currentViewIndex--;
		if (currentViewIndex < 0) 
		{
			currentViewIndex = [views count] - 1;
		}
	} 
	else if (type == 8) 
	{ 
	//kUIViewSwipeRight
		transType = 2;
		currentViewIndex++;

		if (currentViewIndex == [views count]) 
		{
			currentViewIndex = 0;
		}
	}

	//NSLog(@"transition to view %d", currentViewIndex);
	if (transType != 0) 
	{
		[self transition:transType toView: [views objectAtIndex: currentViewIndex]]; 
	}

	// transition to current view
	return [ super swipe:type withEvent:event ];
}

- (void) addView: (id) fp8 
{
	[views addObject: fp8]; 
	if (currentViewIndex == -1) 
	{
		[super addSubview: fp8];
		currentViewIndex = 0;
	}
}

- (void) dealloc 
{
	[views release];
	[super dealloc];
}
@end

@implementation CalculatorApp

- (void) handleCommand: (NSString *) command
{
	//NSLog(@"CalculatorApp handleCommand: [%@]", command);

	// pass the commands down the chain
	[engine sendCommand: command];

	// then update all the views...
	[self updateViews];
}

- (void) updateViews 
{
	[basicCalculatorView updateView];
}

- (void) applicationDidFinishLaunching: (id) fp8 
{
	engine = [[CalculatorEngine alloc] init];


	struct CGRect frame = [UIHardware fullScreenApplicationContentRect];
	frame.origin.x = frame.origin.y = 0.0f;
	mainWindow = [[UIWindow alloc] initWithContentRect: frame];

	masterView = [[MasterView alloc] initWithFrame: frame];


	basicCalculatorView = [[BasicCalculatorView alloc] initWithFrame: frame withController: self withEngine: engine withType: 0];
	[masterView addView: basicCalculatorView];

	sciCalculatorView = [[BasicCalculatorView alloc] initWithFrame: frame withController: self withEngine: engine withType: 1];
	[masterView addView: sciCalculatorView];


	navView = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 48.0f)];
	[navView showButtonsWithLeftTitle: @"Decimal" rightTitle: @"Hex" leftBack: YES];
	[navView setPrompt: @"Caclulator2"];
	[navView setBarStyle: 0];
	[navView enableAnimation];
	//[masterView addView: navView];

	diagView = [[UITouchDiagnosticsLayer alloc] initWithFrame: frame];
	[diagView setDisplayChargeMap: true];
	[diagView setDisplayHitRects: true];
	[diagView setDisplayTouchEvents: true];
	[diagView setTrackTouchEvents: true];
	//[masterView addView: diagView];


	[mainWindow orderFront: self];
	[mainWindow makeKey: self];
	[mainWindow _setHidden: NO]; 
	[mainWindow setContentView: masterView]; 
}

- (void)acceleratedInX:(float)xx Y:(float)yy Z:(float)zz 
{
	NSLog(@"accelerated x=%g, y=%g, z=%g", xx, yy, zz);
}

@end
looks better
Looks good

Quote Originally Posted by frozenasasin View Post
wait u have a mac? MAC BUDDY!
Yes I have a mac, and I have a windows also

Quote Originally Posted by serpentine View Post
Found it, check my edited post!
Good work, thanks for saving me some time
Quote Originally Posted by serpentine View Post
Found it, check my edited post!
then you dont close the else if
Yeah, just noticed that. =/ Check to see if you misplaced any curly brackets. They are all accounted for but they may be in the wrong place.
Quote Originally Posted by serpentine View Post
Yeah, just noticed that. =/ Check to see if you misplaced any curly brackets. They are all accounted for but they may be in the wrong place.
That was my original guess... Good luck I'm gonna go take a shower and go RipSticking. Please don't thank me for my usefullness if I was useful
Posts 1–15 of 33 · Page 1 of 3
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us