我使用3.2.6 iOS 4.3开始。现在我的问题是它告诉我我有一个(位于“(实现窗口,hvController;”):
预期标识符或'(''''标记之前的'
在Delegate.m类
中//HelloUniverseAppDelegate.M
(@Implementation window, hvController;
(...
//HelloUniverseAppDelegate.m
- (void)applicationDidFinishishLaunching:(UIApplication *)application {
HelloUniverseController *hvc = [[HelloUniverseController alloc]
inWihhNibName:@"HelloUniverse" bundle:[NSBundle mainBundle]];
self.hvController = hvc;
[hvc release];
[window addSubview:[self.hvController view]];
// Override point for customization after application launch
[window makeKeyAndVisible ;
}
- (Void)dealloc {
[hvController release];
[window release];
[super dealloc];
}
HelloUniverseController *hvc = [HelloUniverseController alloc];
hvc = [hvc initWithNibName:@"HelloUniverse" bundle:[NSBundle mainBundle]];
#import "HelloUniverseAppDelegate.h"
@implementation HelloUniverseAppDelegate
@synthesize window;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end
now also its telling me I have a similar error in the Controller.h with
Expected Identifier before '{' token
its located on the "- (void)dealloc :{" line. the code I have for it is
#import <UIKit/UIKit.h>
@interface HelloUniverseController : UIViewController {
IBOutlet UITextField *txtFirstName;
IBOutlet UITextField *txtLastName;
IBOutlet UILabel *lblMessage;
}
- (IBAction) btnClickMe_Clicked:(id)sender;
//HelloUniverseController.m
- (void)dealloc :{
[txtFirstName release];
[txtLastName release];
[lblMessage release];
[super dealloc];
}
@end
我也是非常新的,我第二天使用mactonish以及第一次使用Xcode。
答案 0 :(得分:3)
Objective-C要求类有两部分:接口,通常出现在.h文件中,并声明类的实例变量,属性和方法;和实现,它应该在.m文件中并定义类的方法。您似乎试图在@interface块内部而不是@implementation块中定义-dealloc
方法,这导致至少一个您得到的错误。
坦率地说,人们无法避免在不了解语言的情况下从某处复制和粘贴代码的印象。有许多明显的错误没有任何意义,包括我刚才描述的错误和似乎属于-applicationDidFinishLaunching
方法的#import语句。
StackOverflow是一个很棒的社区,我相信,在您学习编程时,我很乐意帮助您。但是,如果您还没有努力学习该语言的基本语法,那么您很快就会受欢迎。更重要的是,如果我们不断纠正您的错误,它真的不会帮助您。请阅读Learning Objective-C: A Primer。或者,如果您对基于C语言(C,C ++,C#,Java ...)和某种形式的面向对象编程没有任何经验,请考虑选择面向初学者的第三方书籍。由于iPhone和iPad的广泛流行,有很多书可供选择。
答案 1 :(得分:2)
删除此
(
之前
(@implementation