0
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.

1
  • Please provide an example string for [deposit text]. Commented May 13, 2011 at 12:21

2 Answers 2

3

Instead of putting NSLog(@"snow"); assign firstThird=@"snow"

Sign up to request clarification or add additional context in comments.

Comments

0

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

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.