점수가 기본 점수 항목 또는 새롭게 설정된 항목보다 높으면 하나의 항목을 완료 할 때 해당 항목과 데이터를 저장하고 다른 모든 것을 푸시합니다. 목록에서 마지막 항목을 제거합니다. 현재 이것은 하나의 교환 일 뿐이며 기능을 위해서 나는 그것을 하드 코딩하고 나중에 리펙토링 할 것이다.해당되는 경우 이름을 입력하는 데 문제가 있습니다
내 주된 문제는 플레이어 입력없이 즉시 플레이어 이름 실행을 계속 실행하고 게임을 중단시키는 텍스트 입력보기를 설정할 때입니다. 내가하려고하는 모든 시도가 실패 할 경우에 대비해 기본 값을 가지고 있기 때문에 텍스트를 설정하는 행을 주석 처리했습니다. 입력을받는 동안 실행을 잠시 대기하도록하려면 어떻게해야합니까? 대리자 메서드를 설정해야합니까? 그렇다면 나는 여전히 대의원들에게 약간 혼란 스럽다. 작동하도록 설정할 수는 있지만 이해가되지 않아 다른 특수한 사용자 지정 작업을 수행 할 수 없습니다. 나는
-(void)saveData:(ScoreKeep *)stats{
NSMutableDictionary *swap = [[NSMutableDictionary alloc]init];//used for swaping entries
NSString *filePath = [self pathOfFile];
NSLog(@"Writing to %@", filePath);
if ([[NSFileManager defaultManager]fileExistsAtPath:filePath]) {
NSLog(@"Loading previous dictionary to save...");
dataDictionary = [NSMutableDictionary dictionaryWithContentsOfFile:filePath];
if ([dataDictionary objectForKey:@"1"]) {
NSMutableDictionary *highScore = [dataDictionary objectForKey:@"1"];
if ([stats.score intValue] > [[highScore objectForKey:@"SCORE"] intValue]) {
NSLog(@"You Win! score: %@ highscore: %@", stats.score,[NSNumber numberWithInt:[[highScore objectForKey:@"SCORE"] intValue]]);
stats = [[ScoreKeep alloc] initWithNibName:@"Scorekeep" bundle:nil];
NSLog(@"Setting up name entry");
[self.view addSubview:stats.view]; //New view is added so that the player can input data(Assume it is complete);
//stats.nameTag = setName.nameTag;//This line is executed before the new view is dismissed causing an error to occur
[stats setupDictionary]; // It just goes down hill from here if the previous line is uncommented
[dataDictionary setObject:stats.sComponents forKey:@"1"];
}else {
NSLog(@"You Lose: %@ highscore: %@", stats.score,[NSNumber numberWithInt:[[highScore objectForKey:@"SCORE"] intValue]]);
}
NSLog(@"Got first place entry");
}else {
NSLog(@"Initilizing Score");
}
}else{
NSLog(@"Creating new dictionary to save...");
dataDictionary = [[NSMutableDictionary alloc]init];
}
[dataDictionary writeToFile:filePath atomically:YES];
}
도움을 주시면 감사하겠습니다 ... 잠시 동안 근무하고 더 없어했습니다. 더 많은 정보가 필요하다면 기꺼이 제공 할 것입니다. 방식 ScoreKeep 의해 는 사전하고 I 필요한 임의의 값을 설정하고 sComponents로 패키지화 할 수 있도록 사전에 작성하는 기능을 포함하는 객체
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@class omphalosUtility;
#pragma mark -
#pragma mark Saving data
#pragma mark -
static inline void poop(){
NSLog(@"POOP");
}
(사전 메인 savefile을 체결 함) 인
필자는 파일을 업데이트하고 필요한 경우 저장과 같은 다른 일반적인 작업을 수행 할 수 있도록 응용 프로그램과 독립적으로 작동하는 유틸리티 파일을 만들려고합니다. 그것의 한 걸음을 내딛고 싶습니다.
코드를 올바르게 표시하여 표시하십시오. 나는 그것을 고치려고했지만 모든 중첩 된 if를 포기했다. – Abizern
죄송합니다. 코드를 고치려고했다. – Ohmnastrum
어쨌든 지저분한 코드 작성에 불편을 끼쳐 드려 죄송합니다. 나는 클래스에이 모든 기능을 구현할 계획을 세웠지 만 그다지 악몽이 아니었다. – Ohmnastrum