我无法在我的数据中检测到不正确的字符。我正在使用 SimplePost 发布数据、PHP
处理数据、存储数据、MySQL
准备PHP的返回以及接收响应,如下所示。我在我的应用程序的几个地方使用它,而且一切通常都很棒。现在我的数据在增长,而且我经常遇到错误。PlistParser
NSURLConnection
SimplePost 正在使用:
NSString *escapedString = (__bridge_transfer NSString *) CFURLCreateStringByAddingPercentEscapes(NULL, (__bridge CFStringRef)([dictionary objectForKey:[keyArray objectAtIndex:i]]),NULL, (CFStringRef)@"!*'();:@&=+$,/?%#[]", kCFStringEncodingUTF8);
这是我的连接代码:
// connection to URL finished with Plist-formatted Questions data array returned from PHP
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
NSString *error;
NSArray *array = (NSArray *)[NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListImmutable format:0 errorDescription:&error];
if( error ) {
NSLog(@"Error = %@", error );
return;
}
错误是:
Unexpected character x at line 1
Encountered unexpected EOF
... and such
当我直接查看 SimplePost 转义字符串或 PHP 函数返回的数据时,我看不到任何异常。我不知道是什么导致了错误。
我可以在某处进行更多过滤以防止此类错误吗?谢谢您的帮助!