NSString *depositOverTotalRwy = [NSString stringWithFormat:@"%@", [deposit text]];
NSArray *components = [depositOverTotalRwy
componentsSeparatedByString:@"/"];
NSString *firstThird = [components objectAtIndex:0];
if ([firstThird isEqualToString: @"1"]) {
NSLog(@"wet");
}
if ([firstThird isEqualToString:@"2"]) {
NSLog(@"snow");
}
if ([firstThird isEqualToString:@"3"]) {
NSLog(@"ice");
}
NSString *secThird = [components objectAtIndex:1];
if ([secThird isEqualToString: @"1"]) {
NSLog(@"wet");
}
if ([secThird isEqualToString:@"2"]) {
NSLog(@"snow");
}
if ([secThird isEqualToString:@"3"]) {
NSLog(@"ice");
}
NSString *thirdThird = [components objectAtIndex:2];
if ([thirdThird isEqualToString: @"1"]) {
NSLog(@"wet");
}
if ([thirdThird isEqualToString:@"2"]) {
NSLog(@"snow");
}
if ([thirdThird isEqualToString:@"3"]) {
NSLog(@"ice");
}
dep.text = [NSString stringWithFormat:@"%@ over %@ over %@", firstThird, secThird, thirdThird];
嗨,大家好, 我有一個問題。當我設置標籤(dep.text)時,我得到的數字不是溼,雪或冰。它在控制檯(NSlog)中工作。 我知道它一定是邏輯上的一些錯誤,但我無法找到它。提前致謝。String and array
請提供'[deposit text]'的示例字符串。 – Anne 2011-05-13 12:21:04
@安妮2/3/3 .....謝謝 – mat 2011-05-13 12:25:22