Reputation: 6324
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];
Hi guys, I have a problem. when I set the label (dep.text), I get the number instead of wet, snow or ice. it works in the console (NSlog). I know it must be some error in the logic but i'm not able to find it. Thanks in advance.
Upvotes: 0
Views: 59
Reputation: 12900
it looks to me as it the objects within components are @"1", @"2" or @"3".
dep.text is reflecting that
for dep.text to resemble what you wish, you need to set the strings, something like -
thirdThird = @"wet";
thirdThird = @"snow";
thirdThird = @"ice";
inside the conditions of course
}
Upvotes: 0