2010-01-25 4 views
1

내가 필요로하는 정보를 찾지 못해서 "필요한 정보를 찾지 못했습니다." "saveDataround"버튼을 선택할 때 배열에 저장하려는 개체가 있습니다. 개체에 "Round"텍스트를 채우는 방법 : "예상 된 식별자"및 "예상 됨;"이 표시됩니다. 첫 번째 및 두 번째 코드 줄에 오류가 있습니다. 미리 감사드립니다."텍스트"가 포함 된 개체 추가

[NSString *roundChoice = [NSString stringWithFormat:@"Round"]; 
self.round.text = roundChoice;] 

- (IBAction)saveDataround { 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *recipient = [NSString stringWithFormat:@"%@/arrayChoiceRound", documentsDirectory]; 
    NSMutableArray *array = [[NSMutableArray alloc] init]; 
    [array addObject:round.text]; 
    [array writeToFile:recipient atomically:NO]; 
} 

답변

1

처음 두 줄의 코드는 어디에 구현됩니까? 그들이 무엇을하기로되어 있나? 여기

내가 더 많은 정보없이 위의 코드를 수정하는 것입니다 방법은 다음과 같습니다

// remove "[" from start of line & no need to use stringWithFormat here 
NSString *roundChoice = @"Round"; 

// remove "]" from end of line 
self.round.text = roundChoice; 

- (IBAction)saveDataround { 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 

    // use stringByAppendingPathComponent here 
    NSString *recipient = [documentsDirectory stringByAppendingPathComponent:@"arrayChoiceRound"]; 
    NSMutableArray *array = [[NSMutableArray alloc] init]; 

    // use self here (not required) 
    [array addObject:self.round.text]; 

    [array writeToFile:recipient atomically:NO]; 

    // release the array 
    [array release]; 
} 
+0

일뿐만 아니라 구문 오류를 수정뿐만 아니라 코드를 향상. –

+0

감사합니다. 여전히 '=', ',', ';', 'asm'또는 '__attribute__'앞에 ':'오류가 표시됩니다. 토큰 after self.round.text = roundChoice; –

+0

죄송합니다, 처음 두 줄에 대해서, 나는 그들이 어디로 가야하는지 모르겠습니다 ... –

관련 문제