2013-06-05 4 views
0

나는 내가 이미 작업이 아닌 만들고있어 튜토리얼 (사용하여 코드를 완성하고있어 http://mobileorchard.com/how-to-make-an-iphone-app-part-6-saving-data/ 튜토리얼 다음 홈 버튼을 쳤을 때 내 응용 프로그램을 저장하기 위해 노력하고있어 신고되지 않은 있습니다엑스 코드는

#import "Spalsh_XcodeAppDelegate.h" 
#import "MainControllerView.h" 

@implementation Spalsh_XcodeAppDelegate 
@synthesize window=_window; 


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions (NSDictionary *)launchOptions 
{ 
    MainControllerView *mainController = [[MainControllerView alloc] init]; 

[_window addSubview:mainController.view]; 

// 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 
{ 
//TEST 
NSArray *values = [[NSArray alloc] initWithObjects:q1.text,q2.text,nil]; 
[values writeToFile:[self saveFilePath] atomically:YES]; 
[values release]; 
//TEST 
} 

- (void)applicationWillEnterForeground:(UIApplication *)application 
{ 
/* 
Called as part of the 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. 
Save data if appropriate. 
See also applicationDidEnterBackground:. 
*/ 
} 

- (void)dealloc 
{ 
[_window release]; 
[super dealloc]; 
} 

@end 
+0

.h 코드를 표시하고 인터페이스 작성기에서 q1과 q2를 연결 했습니까? – JSA986

+0

인터페이스 빌더에 q1과 q2를 연결하려면 어떻게해야합니까? –

+0

appDeleagte에 대한 코드가 있습니다. MainControllerView.h의 .h 및 .m 코드는 어디에 있습니까? – JSA986

답변

0

그러나 : 튜토리얼에 대한 새로운 것을) 나는 오류의 1 분기가 2 분기 (그들은 내 텍스트 상자

- (void)applicationDidEnterBackground:(UIApplication *)application 
{ 
//TEST 
NSArray *values = [[NSArray alloc] initWithObjects:q1.text,q2.text,nil]; 
[values writeToFile:[self saveFilePath] atomically:YES]; 
[values release]; 
//TEST 
} 

이 내 뷰에 대한 .H이다) IB에 신고되지 않은 있습니다된다 q1 및 q2 텍스트 필드가 선언 되었습니까? 어떤 뷰 컨트롤러에서 Interface Builder 또는 코드를 통해 인터페이스를 만들었습니까? 그리고 그들이 어떻게 에서 NSArray 개체에 당신이 그것을 추가하는 방법에 인정 될 것입니까?

내가보기에 일부보기 컨트롤러의 텍스트 필드 텍스트에서 값을 의 applicationDidEnterBackground 방법으로 저장하려고합니다. 이렇게하려면 텍스트를 일부 속성에 저장해야합니다. 뷰 계층에서 뷰 컨트롤러를 가리키고 해당 인스턴스의 해당 속성에서 해당 문자열을 가져옵니다. 그리고 그곳에서 배열로 저장하거나 다른 절차를 수행 할 수 있습니다.