View concurrency6.swift
import UIKit | |
import PlaygroundSupport | |
//to run serial queue in playground always make the following true | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
let mainQueue = DispatchQueue.main | |
let globalQueue = DispatchQueue.global() | |
let serialQueue = DispatchQueue(label: "net.ithinkdiff.app") | |
let concurQueue = DispatchQueue(label: "net.ithinkdiff.app.concurr", attributes: .concurrent) |
View optionals1.swift
var score:Int? | |
score = 100 | |
//if score is nil the if block will not work | |
/*if score has value, the if block create a new constant score and assign the score value to the new constant score which is unwrapped and available within the if block | |
*/ | |
if let score = score{ | |
score | |
} | |
score ?? 0 //provide a default value when there is nil | |
score! //when u sure the optional must have a value other than nil |
View typeannotation.swift
var x // error | |
var x:Int // okay |
View ios_detect.swift
struct Device { | |
// iDevice detection code | |
static let IS_IPAD = UIDevice.current.userInterfaceIdiom == .pad | |
static let IS_IPHONE = UIDevice.current.userInterfaceIdiom == .phone | |
static let IS_RETINA = UIScreen.main.scale >= 2.0 | |
static let SCREEN_WIDTH = Int(UIScreen.main.bounds.size.width) | |
static let SCREEN_HEIGHT = Int(UIScreen.main.bounds.size.height) | |
static let SCREEN_MAX_LENGTH = Int( max(SCREEN_WIDTH, SCREEN_HEIGHT) ) | |
static let SCREEN_MIN_LENGTH = Int( min(SCREEN_WIDTH, SCREEN_HEIGHT) ) |
View ios_detect.h
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) | |
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) | |
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0) | |
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width) | |
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height) | |
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT)) | |
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT)) |
View properties.swift
class Properties{ | |
static let sharedInstance = Properties() | |
private let userDefaults:UserDefaults = UserDefaults() | |
var fontSize:Double = 10.0{ | |
didSet{ | |
userDefaults.setValue(fontSize, forKey: "FONT_SIZE") | |
userDefaults.synchronize() | |
print("Font Size Saved") | |
} |
View xpa1.rb
#!/usr/bin/ruby | |
#XCode modification | |
require 'xcodeproj' | |
bundleId = ARGV[0] | |
path = ARGV[1] | |
project_path = path + "/XCodeProject.xcodeproj" | |
puts(project_path) |
View xpa2.py
def modifyXCodeProjByRuby(bundleIdentifier, path): | |
print("XCode Project Modified by Ruby") | |
rubyModifyCommand = "ruby RUBY_FILE_NAME.rb " + "\"" + bundleIdentifier + "\"" + " " + "\"" + path + "\"" | |
print(rubyModifyCommand) | |
os.system(rubyModifyCommand) |
View xpapy1.py
import os | |
import shutil | |
import subprocess | |
import plistlib |
View xpapy2.py
try: | |
removeIcons = "/app_directory/app_name/Images.xcassets/AppIcon.appiconset" | |
shutil.rmtree(removeIcons) | |
print("Icons deleted") | |
except: | |
print("ERROR: Icons not found") |
OlderNewer