문제

i want to create arrays with different *names (the text out of a textField should be the name of the array) when an IBAction function is called. How do i get the text out of the text field and make it the *name of the array?

- (IBAction)createButton:(id)sender {
    NSMutableString *string = [[NSMutableString alloc] init];
    [string setString:[textField text]];
    NSMutableArray *string = [[NSMutableArray alloc] init];
}
도움이 되었습니까?

해결책

Create a NSDictionary and use the string as key, and array as value.

다른 팁

try this . . .

- (IBAction)createButton:(id)sender {

    NSString *string = [textField text];

    NSMutableArray *array = [string componentsSeparatedByString:@" "];
}

if names are separated by space , then provide space , if they are separated by comma ',' then

// NSMutableArray *array = [string componentsSeparatedByString:@","];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top