Hi folks,
I'm not new to programming but I am new to programming in Objective-c (I come from a Java background).
I'm currently trying to wade my way through the iPhone development course that Stanford are running. I have managed to finish Assignment 3, and I'm looking to try and do the extra credit, however I'm having problems saving the state.
Looking online I could see recommendations for using 'applicationWillTerminate' in the app delegate. In order to save the state of the polygon I thought that the best thing to do would be to create an IBOutlet to the controller, so that the delegate can see the polygon object.
implementation file
The code above compiles and runs fine with no errors or warnings, but when I add add the following line in bold:
I get an error message under the import statement in the .m file:
error: syntax error before 'Controller'.
According to most sites that I have looked at to try and fix this problem, most have advised that there is something wrong with the header file, such as a bracket or semi-colon missing, but I just can't see it.
Xcode automatically recognizes and autocompletes when I begin to type 'Controller', so I don't think that it's a case that it can't see the Controller class.
Can anyone advise as to how this is happening?
Many thanks
I'm not new to programming but I am new to programming in Objective-c (I come from a Java background).
I'm currently trying to wade my way through the iPhone development course that Stanford are running. I have managed to finish Assignment 3, and I'm looking to try and do the extra credit, however I'm having problems saving the state.
Looking online I could see recommendations for using 'applicationWillTerminate' in the app delegate. In order to save the state of the polygon I thought that the best thing to do would be to create an IBOutlet to the controller, so that the delegate can see the polygon object.
Code:
// HelloPolyAppDelegate.h
#import <UIKit/UIKit.h>
@interface HelloPolyAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@end
implementation file
Code:
// HelloPolyAppDelegate.m
#import "HelloPolyAppDelegate.h"
@implementation HelloPolyAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Override point for customization after application launch
[window makeKeyAndVisible];
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end
The code above compiles and runs fine with no errors or warnings, but when I add add the following line in bold:
Code:
// HelloPolyAppDelegate.h
#import <UIKit/UIKit.h>
@interface HelloPolyAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
[B]IBOutlet Controller *controller;[/B]
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@end
I get an error message under the import statement in the .m file:
error: syntax error before 'Controller'.
According to most sites that I have looked at to try and fix this problem, most have advised that there is something wrong with the header file, such as a bracket or semi-colon missing, but I just can't see it.
Xcode automatically recognizes and autocompletes when I begin to type 'Controller', so I don't think that it's a case that it can't see the Controller class.
Can anyone advise as to how this is happening?
Many thanks