Skip to content

Instantly share code, notes, and snippets.

@adsl99801
Last active March 21, 2018 02:32
Show Gist options
  • Save adsl99801/061d789d42e1382f87e5728db36a126e to your computer and use it in GitHub Desktop.
Save adsl99801/061d789d42e1382f87e5728db36a126e to your computer and use it in GitHub Desktop.
IOS Objectivec
NSString* fontName = [[AppDelegate getSetting] fontName];
int fontSize = [[AppDelegate getSetting] fontSize];
@adsl99801
Copy link
Author

ad = (AppDelegate*)[[UIApplication sharedApplication] delegate];
NSString* fontName = [[AppDelegate getSetting] fontName];
int fontSize = [[AppDelegate getSetting] fontSize];

@adsl99801
Copy link
Author

let result=newsPageVos.map({return $0.newsChannel.display_name}).reduce(""){$0+$1}

@adsl99801
Copy link
Author

adsl99801 commented Jan 30, 2018

        android intent 在ios 類似的功能 
let fileUrl=response.dest
            CommonUtils().printLog("\(fileUrl)")
//            let file = try Data(contentsOf: fileUrl)  will not effect
            let file = NSURL(fileURLWithPath: fileUrl.absoluteString)
            let activityViewController: UIActivityViewController = UIActivityViewController(activityItems: [file], applicationActivities:nil)
            activityViewController.popoverPresentationController?.sourceView = self.lb_attachName
            DispatchQueue.main.async {
                self.present(activityViewController, animated: true, completion: nil);
            }

@adsl99801
Copy link
Author

adsl99801 commented Jan 30, 2018

import Foundation
class FileTool{
    public func dir() -> URL {
        return FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
    }
    public func documentsDir() -> String {
        
        var paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) as [String]
        return paths[0]
    }
    
    public func cachesDir() -> String {
        var paths = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true) as [String]
        return paths[0]
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment