Skip to content

Instantly share code, notes, and snippets.

@OctoberHammer
OctoberHammer / sendRequest
Last active May 17, 2017 10:38
cutl into Alamofire
#Есть HTTP-запрос, который выполняется например из терминала
##Request
-X GET -H "Content-Type: application/x-www-form-urlencoded" -H "X-Parse-Application-Id: ad383bxkAmwAgKgPEqZHjewleWi2bLmNTlctBuky" -H "X-Parse-Master-Key: qTJ3eatgZppvAWqkb82WsCoqG9MqRog2MBXqRHHv" -d "where={\"parentID\":{\"\$exists\":false}}" https://parseapi.back4app.com/classes/category
#Пруф:
https://www.dropbox.com/s/qd0fkay5nnvf4bc/Terminal.png?dl=0
func sendRequestRequest() {
/**
Request
get https://parseapi.back4app.com/classes/category
*/
// Add Headers
let headers = [
"X-Parse-Master-Key":"qTJ3eatgZppvAWqkb82WsCoqG9MqRog2MBXqRHHv",
"X-Parse-Application-Id":"ad383bxkAmwAgKgPEqZHjewleWi2bLmNTlctBuky",
@OctoberHammer
OctoberHammer / Playground.swift
Last active May 27, 2017 19:53
Convert from Any? into Int32?
//: Playground - noun: a place where people can play
import UIKit
import Foundation
//Пробовать с разными - раскоментаривать по очереди
var someString: String? = "bjbb"
//var someString: String? = "3456"
//var someString: Int? = 3456
@OctoberHammer
OctoberHammer / playground.swift
Created May 28, 2017 18:01
Modify Value for a certain key of a Dictionary
//: Playground - noun: a place where people can play
import UIKit
import Foundation
var dictOfProductsForCategory: [Int: [[String:Any]]] = [:]
//I want dictOfProductsForCategory[3183] eventually to be set with 4-items Array
//How can I do this?
var result1: [[String:Any]]? = [["id":5, "title": "Some Title"], ["id":6, "title": "Another Title"]]
import UIKit
import Foundation
class ConnectBLE {
var callBackFunc: ()->()
init(callFunc: @escaping () -> ()){
callBackFunc = callFunc
}
}
//: Playground - noun: a place where people can play
import UIKit
import Foundation
enum MyErrors: Error {
case DivisionByZero
}
//MARK: Описываем функцию, которая будент выкидывать исключение, при попытке деления на ноль.
func divide(_ what: Float, by divider: Float) throws -> Float? {
Your code here
class ViewControllerAdd: UIViewController {
var delegate : DataTableView?
@IBAction func exittoVC(_ sender: Any) {
delegate?.relodeTableView()
self.dismiss(animated: true, completion: nil)
}
}
class ViewControllerAdd: UIViewController {
var delegate : DataTableView?
@IBAction func exittoVC(_ sender: Any) {
delegate?.relodeTableView()
self.dismiss(animated: true, completion: nil)
}
}
@OctoberHammer
OctoberHammer / delgate, reloaddata
Last active September 30, 2022 11:03
swift.swift
import Foundation
import UIKit
class ViewControllerAdd: UIViewController {
var delegate : DataTableView?
@IBAction func exittoVC(_ sender: Any) {
delegate?.relodeTableView()
self.dismiss(animated: true, completion: nil)