This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
//It basically just gets image from assets, saves its data to disk and return file URL. | |
class AssetExtractor { | |
static func createLocalUrl(forImageNamed name: String) -> URL? { | |
let fileManager = FileManager.default | |
let cacheDirectory = fileManager.urls(for: .cachesDirectory, in: .userDomainMask)[0] | |
let url = cacheDirectory.appendingPathComponent("\(name).png") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func showAlert(message: String) { | |
let alert = UIAlertController(title: "Link", message: message, preferredStyle: .alert) | |
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in | |
switch action.style{ | |
case .default: | |
print("default") | |
case .cancel: | |
print("cancel") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask { | |
if window == self.window { | |
return .portrait | |
} else { | |
return .allButUpsideDown | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Read String array separated by new line character | |
func readInput () -> [String]{ | |
let n: Int = Int(readLine()!)! | |
var strs = [String]() | |
(0...n-1).map { _ in | |
strs.append(readLine()!.lowercased()) | |
} | |
return strs | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let API_HEADER_FIELD_NONE_MATCH : String = "If-None-Match" | |
let API_HEADER_FIELD_ETAG : String = "Etag" | |
let API_REQUEST_SUCCESS : Int = 200 | |
func ETagForURL(urlString: String) -> String? { | |
// return the saved ETag value for the given URL | |
return NSUserDefaults.standardUserDefaults().objectForKey(urlString) as String? | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MyWKWebVC.Swift | |
// Example | |
// | |
// Created by Fahied on 04/01/2017. | |
// | |
import Foundation | |
import UIKit | |
import WebKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
After some digging through the storyboard source code, it turns out that the iPad storyboard was copied from the iPhone storyboard. So, the question really became how do I convert an iPhone storyboard into an iPad storyboard? | |
The answer is surprisingly simple. I ran across this SO answer -- to convert an iPhone storyboard to an iPad storyboard, do the following: | |
From Xcode, right-click on the storyboard and choose Open As -> Source code | |
Search for targetRuntime="iOS.CocoaTouch"and change it to targetRuntime="iOS.CocoaTouch.iPad" | |
Right-click on the storyboard again and choose Open As -> iOS Storyboard | |
The storyboard will now show all views in the correct size. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Development Phase: | |
Step 1: Create Certificate .pem from Certificate .p12 | |
Command: openssl pkcs12 -clcerts -nokeys -out apns-dev-cert.pem -in apns-dev-cert.p12 | |
Step 2: Create Key .pem from Key .p12 | |
Command : openssl pkcs12 -nocerts -out apns-dev-key.pem -in apns-dev-key.p12 | |
Step 3: Optional (If you want to remove pass phrase asked in second step) | |
Command : openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Following is code for find all fonts from the system: | |
for(NSString *fontfamilyname in [UIFont familyNames]) | |
{ | |
NSLog(@"Family:'%@'",fontfamilyname); | |
for(NSString *fontName in [UIFont fontNamesForFamilyName:fontfamilyname]) | |
{ | |
NSLog(@"\tfont:'%@'",fontName); | |
} | |
NSLog(@"~~~~~~~~"); |