I've this following code segment. The output for the integer variable comes as expected in iOS 5, but some irregular output is coming in iOS 6! Can anyone please explain what's happening?

int XmlMsgSubType;
[XmlMsgSubTypeData getBytes:&XmlMsgSubType length:1];
NSLog(@"XML subtype data: %@", XmlMsgSubTypeData);
NSLog(@"XML subtype: %d", XmlMsgSubType);

Output in iOS 5

XML subtype data: <06>
XML subtype: 6

Output in iOS 6

XML subtype data: <06>
XML subtype: 985605638
有帮助吗?

解决方案

If for some reason on ios 6 there is no data in the XmlMsgSubTypeData object, then XmlMsgSubType would be uninitialized and therefore the value returned would be undefined. I suspect the actually error is happening where you read the data into XmlMsgSubTypeData. Try calling [XmlMsgSubType length] to check it is not zero.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top