Convert NSString to fetch synthesized information.
- by Max
//COPY THIS CODE IN A FRESH PROJECT!!!
//THIS 2 LINES ARE JUST EXAMPLES, IN REAL THEY ARE NOT STATIC!
NSString *messagelevel1 = @"45";
NSString *messagelevel = @"1";
NSString *HuidigLevel = messagelevel;
NSDecimalNumber *huidigleveldec = [[NSDecimalNumber alloc] initWithString: HuidigLevel];
float HuidigLevelRek = [huidigleveldec floatValue];
//HERE IS THE PROBLEM
NSString* LevelTotaal=[[NSString alloc] initWithFormat:@"messagelevel%.f",HuidigLevelRek];
NSString*result = LevelTotaal;
NSLog(@"%@",result);
// THIS RESULT SHOULD RETURN THE SAME VALUE AS THE LINE UNDER THIS LINE!
NSLog(@"%@",messagelevel1);
I want the *result string behaves like the *huidiglevel string and fetch some information, but because the LevelTotaal is a NSString, It doesn't fetch this information. I really got no idea where to google for this problem, searching the Developer docs didn't helped either . Maybe you guys can help me out?
Actually the second NSLog returns the value and to first NSLog just returns messagelevel1. To tell you in short ;)
I hope you guys get what I'm saying!