Преглед изворни кода

Socket용 공통 Model 적

KaRam Kim пре 8 година
родитељ
комит
7de76bca7d
1 измењених фајлова са 12 додато и 11 уклоњено
  1. 12 11
      OneCable/Classes/Handler/SocketServiceHandler.m

+ 12 - 11
OneCable/Classes/Handler/SocketServiceHandler.m

@@ -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:)]) {