|
|
@@ -196,22 +196,23 @@
|
|
|
else
|
|
|
{
|
|
|
NSError* error = nil;
|
|
|
- NSString *JSONString = [[NSString alloc] initWithData:message encoding:NSUTF8StringEncoding];
|
|
|
- id rawJSON = [NSJSONSerialization JSONObjectWithData:message
|
|
|
+// NSString *JSONString = [[NSString alloc] initWithData:[message dataUsingEncoding:NSUTF8StringEncoding] encoding:NSUTF8StringEncoding];
|
|
|
+ NSDictionary *jsonObj = [NSJSONSerialization JSONObjectWithData:[message dataUsingEncoding:NSUTF8StringEncoding]
|
|
|
options:NSJSONReadingAllowFragments
|
|
|
error:&error];
|
|
|
|
|
|
id JSONModel = nil;
|
|
|
|
|
|
- if ([rawJSON isKindOfClass:[NSArray class]])
|
|
|
- {
|
|
|
- NSDictionary *JSONDic = @{@"list": rawJSON};
|
|
|
- JSONModel = [[SocketModel alloc] initWithDictionary:JSONDic error:&error];
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- JSONModel = [[SocketModel alloc] initWithString:JSONString error:&error];
|
|
|
- }
|
|
|
+// if ([jsonObj isKindOfClass:[NSArray class]])
|
|
|
+// {
|
|
|
+// NSDictionary *JSONDic = @{@"list": jsonObj};
|
|
|
+//
|
|
|
+// }
|
|
|
+// else
|
|
|
+// {
|
|
|
+// JSONModel = [[SocketModel alloc] initWithString:JSONString error:&error];
|
|
|
+// }
|
|
|
+ JSONModel = [[SocketModel alloc] initWithDictionary:jsonObj error:&error];
|
|
|
|
|
|
if (self.delegate && [self.delegate respondsToSelector:@selector(socketDidReceiveMessage:)]) {
|
|
|
|