Convert NSString to fetch synthesized information.

Posted by Max on Stack Overflow See other posts from Stack Overflow or by Max
Published on 2011-02-27T21:07:58Z Indexed on 2011/02/27 23:24 UTC
Read the original article Hit count: 271

Filed under:
|
|
//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!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about convert