2012-07-31 68 views
0

這是工作較早,但現在它不是因爲它無法識別下面的第一個.m文件中的設置。我做了#import Setting.h,但它仍然不起作用。請幫忙!「未申報」的未知錯誤

這裏是.h文件:

#import <UIKit/UIKit.h> 
#import "EditNameViewController.h" 



@interface SettingsViewController : UIViewController <EditNameDelegate>{ 

IBOutlet UIButton *froshsched; 
IBOutlet UIButton *uppersched; 


} 

.m文件。它說,設置和「設置未申報

#import "SettingsViewController.h" 
#import "Settings.h" 

@interface SettingsViewController() 

@end 

@implementation SettingsViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
if (self) { 
    self.title = NSLocalizedString(@"Settings", @"Settings"); 
    self.tabBarItem.image = [UIImage imageNamed:@"spanner"];   
    // Custom initialization 
} 
return self; 
} 

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
// Do any additional setup after loading the view from its nib. 
} 

- (void)viewDidUnload 
{ 
[super viewDidUnload]; 
// Release any retained subviews of the main view. 
// e.g. self.myOutlet = nil; 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation 
{ 
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} else { 
    return YES; 
} 
} 

-(IBAction)froshsched{ 
Settings *settings = [Settings sharedInstance]; 
settings.timelabelfirst = @"12:35"; 
settings.timelabelsecond = @"1:25"; 
[[Settings sharedInstance] save]; 
} 
-(IBAction)uppersched{ 
Settings *settings = [Settings sharedInstance]; 
settings.timelabelfirst = @"12:10"; 
settings.timelabelsecond = @"1:00"; 
[[Settings sharedInstance] save]; 
} 

-(IBAction)editclass{ 
EditNameViewController*vc2 = [[EditNameViewController alloc] init]; 
vc2.delegate = self; 
[self presentModalViewController:vc2 animated:YES]; 
} 

-(void)dismiss{ 
[self dismissModalViewControllerAnimated:YES]; 
} 

@end 


-(IBAction)editclass; 
-(IBAction)froshsched; 
-(IBAction)uppersched; 

這裏是Settings.h

#import <Foundation/Foundation.h> 

@interface Settings : NSObject 

@property (nonatomic) NSString *redClassName, *orangeClassName, *yellowClassName, *greenClassName, *ltblueClassName, *dkblueClassName, *purpleClassName, *pinkClassName, *timelabelfirst, *timelabelsecond; 

+(Settings*)sharedInstance; 
-(void)save; 

@end 

,最後這裏是Settings.m文件,我覺得我失去了一些東西簡單,感謝

#import "Settings.h" 

@implementation Settings 

@synthesize redClassName, orangeClassName, yellowClassName, greenClassName, ltblueClassName, dkblueClassName, purpleClassName, pinkClassName, timelabelfirst, timelabelsecond; 

-(id)init{ 
self = [super init]; 
if(self){ 
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    redClassName = [defaults objectForKey:@"kredClass"]; 
    orangeClassName = [defaults objectForKey:@"korangeClass"]; 
    yellowClassName = [defaults objectForKey:@"kyellowClass"]; 
    greenClassName = [defaults objectForKey:@"kgreenClass"]; 
    ltblueClassName = [defaults objectForKey:@"kltblueClass"]; 
    dkblueClassName = [defaults objectForKey:@"kdkblueClass"]; 
    purpleClassName = [defaults objectForKey:@"kpurpleClass"]; 
    pinkClassName = [defaults objectForKey:@"kpinkClass"]; 
    timelabelfirst = [defaults objectForKey:@"ktime1"]; 
    timelabelsecond = [defaults objectForKey:@"ktime2"]; 
} 
return self; 
} 

+(Settings*)sharedInstance{ 
static Settings *sharedSettings; 
if(!sharedSettings) sharedSettings = [[Settings alloc] init]; 
return sharedSettings; 
} 
-(void)save{ 
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
[defaults setObject:redClassName forKey:@"kredClass"]; 
[defaults setObject:orangeClassName forKey:@"korangeClass"]; 
[defaults setObject:yellowClassName forKey:@"kyellowClass"]; 
[defaults setObject:greenClassName forKey:@"kgreenClass"]; 
[defaults setObject:ltblueClassName forKey:@"kltblueClass"]; 
[defaults setObject:dkblueClassName forKey:@"kdkblueClass"]; 
[defaults setObject:purpleClassName forKey:@"kpurpleClass"]; 
[defaults setObject:pinkClassName forKey:@"kpinkClass"]; 
[defaults setObject:timelabelfirst forKey:@"ktime1"]; 
[defaults setObject:timelabelsecond forKey:@"ktime2"]; 
[defaults synchronize]; 
} 

@end 
+0

我相信它並不複雜,我只是想提供儘可能多的信息,這是我需要幫助的最後一件事, – 2012-07-31 01:07:17

+0

請填寫完整的錯誤信息 – 2012-07-31 01:13:45

+0

您使用的是GCC還是LLVM? – 2012-07-31 01:20:28

回答

0

你沒有給我們EditNameController(及其委託)。在任何情況下,我複製並粘貼所有代碼的上方,通過註釋掉EditNameController相關的項目這一切編譯罰款(當然除了這些線浮在你的文件底部:

-(IBAction)editclass; 
-(IBAction)froshsched; 
-(IBAction)uppersched; 

您還沒有顯示一個「 @end「在SettingsViewController.h(我在編譯前添加)的底部。