Browse Source

remove singleton

Marino Faggiana 7 years ago
parent
commit
4cf785e332

+ 0 - 2
iOSClient/Library/NCUchardet/NCUchardet.h

@@ -27,8 +27,6 @@
 
 @interface NCUchardet : NSObject
 
-+ (NCUchardet *)sharedNUCharDet;
-
 - (NSString *)encodingStringDetectWithData:(NSData *)data;
 - (CFStringEncoding)encodingCFStringDetectWithData:(NSData *)data;
 

+ 0 - 10
iOSClient/Library/NCUchardet/NCUchardet.m

@@ -32,16 +32,6 @@
 
 @implementation NCUchardet
 
-+ (NCUchardet *)sharedNUCharDet {
-    static NCUchardet *nuCharDet;
-    @synchronized(self) {
-        if (!nuCharDet) {
-            nuCharDet = [NCUchardet new];
-        }
-        return nuCharDet;
-    }
-}
-
 - (id)init
 {
     self = [super init];

+ 3 - 1
iOSClient/Main/CCDetail.m

@@ -389,7 +389,9 @@
         [headRequest setHTTPMethod:@"HEAD"];
         
         NSURLSessionDataTask *task = [session dataTaskWithRequest:headRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
-            NSString *encodingName = [[NCUchardet sharedNUCharDet] encodingStringDetectWithData:data];
+            
+            NCUchardet *nsuCharDet = [NCUchardet new];
+            NSString *encodingName = [nsuCharDet encodingStringDetectWithData:data];
             [self.webView loadData:[NSData dataWithContentsOfURL: url] MIMEType:response.MIMEType characterEncodingName:encodingName baseURL:url];
         }];
         

+ 4 - 0
iOSClient/Text/NCText.swift

@@ -64,9 +64,13 @@ class NCText: UIViewController, UITextViewDelegate {
             
             if let data = data {
             
+                /*
                 let encodingCFName = NCUchardet.sharedNUCharDet().encodingCFStringDetect(with: data as Data)
                 let se = CFStringConvertEncodingToNSStringEncoding(encodingCFName)
                 let encoding = String.Encoding(rawValue: se)
+                */
+                
+                let encoding = String.Encoding.utf8
                 
                 loadText = try? String(contentsOfFile: path, encoding: encoding)
                 textView.text = loadText