Ok I am not sure how or why this is working but if someone could explain this to me it would be greatly appreciated.
I am debugging an iPhone app and Xcode gives me the following warning, which is correct: "Format Specifies type 'int' but the Argument has a Type 'NSString'.
The code below returns a number, but if I set it to a string it returns a very long string. I know that they wanted the integer and not the string, but I do not know why this would return a number for a string because when I do change it using [str intValue] I get "0" not the long number. So how is this working, can someone explain this to me?
Here is the code:
- (void) FooBar:(NSString *)myStr
{
NSString *callback = [NSString stringWithFormat:@"Some Text Here(%i)", myStr];
[self.webView stringByEvaluatingJavaScriptFromString:callback];
}
Ok let me show you what I mean, and don't worry about the string being passed please. I just want to know how it produces a number like what is shown below from it. I did three NSLogs:
- (void) FooBar:(NSString *)myStr
{
NSString *callback = [NSString stringWithFormat:@"Some Text Here(%i)", myStr];
NSLog(@"NSString = %@", myStr);
NSLog(@"Percent i = %i", myStr);
NSLog(@"Percent i = %i", [myStr intValue]);
[self.webView stringByEvaluatingJavaScriptFromString:callback];
}
Results:
NSString = /__utm.gif?utmwv=4.8mi&utmn=1220166202&utmt=event&utme=5(Init*shoutzVersion*iPhone%20Simulator)(1)&utmcs=UTF-8&utmsr=320x480&utmsc=24-bit&utmul=en-us&utmac=UA-28151051-1&utmcc=__utma%3D1.1697021890.1347557664.1348092917.1348092961.195%3B&utmht=1348092961213&utmqt=9984
Percent i = 154448576
Percent i = 0
Anyone know why this happens?
Thank You!