Skip to content

Instantly share code, notes, and snippets.

View ikju's full-sized avatar
๐Ÿ 
Working from home

Ik Ju Song ikju

๐Ÿ 
Working from home
View GitHub Profile
let parameters : Parameters = ["a" : "b","c" : "d"]
// 1๋ฒˆ ์ฝ”๋“œ๊ฐ€ ์•ˆ๋ ์‹œ 2๋ฒˆ ์ฝ”๋“œ๋กœ encodeing ์ฐจ์ด
1. AF.request("์—ฌ๊ธฐ๋Š” url๋„ฃ์œผ์‹œ์˜ค", method: .post, parameters: parameters, encoding: JSONEncoding.default, headers: nil)
2. AF.request("์—ฌ๊ธฐ๋Š” url๋„ฃ์œผ์‹œ์˜ค", method: .post, parameters: parameters, encoding: URLEncoding.httpBody, headers: nil)
.responseJSON{ response in
debugPrint(response)
switch response.result {
import UIKit
class ViewController: UIViewController, UITextFieldDelegate {
@IBOutlet var textField: UITextField! // Link this to a UITextField in Storyboard
override func viewDidLoad() {
super.viewDidLoad()
textField.smartInsertDeleteType = UITextSmartInsertDeleteType.no
Request
๊ฐ€์žฅ ๊ฐ„๋‹จํ•œ url ํ˜ธ์ถœ์ž…๋‹ˆ๋‹ค.
func get(completionHandler: @escaping (AFDataResponse<Data?>) -> Void){
AF.request("\(Config.baseURL)").response(completionHandler: completionHandler)
}
// ...
func get_alamofire(){
//
// ViewController.swift
// customCameraView
//
// Created by Ik ju Song on 2019/11/12.
// Copyright ยฉ 2019 Ik ju Song. All rights reserved.
//
import UIKit
import AVFoundation
//์˜ˆ์ œ ์ฝ”๋“œ
let alert = UIAlertController(title: "์‚ฌ์ง„์„ ์ „์†กํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?", message: "", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "๋„ค", style: .default, handler:
{ action in
//action ํ•  ๋ฉ”์„œ๋“œ๋‚˜ ์ฝ”๋“œ ๋„ฃ์œผ๋ฉด๋จ ์—ฌ๊ธฐ์—๋‹ค๊ฐ€
}))
alert.addAction(UIAlertAction(title: "์•„๋‹ˆ์š”", style: .cancel, handler: nil))
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
ApplicationDelegate.shared.application( application, didFinishLaunchingWithOptions: launchOptions )//Facebook loing ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋œ ์ฝ”๋“œ
// Override point for customization after application launch.
FBSDKCoreKit.Settings.appID = "์•ฑID"//์•ฑ ID : ํŽ˜์ด์Šค๋ถ ํŽ˜์ด์ง€์—์„œ ๋ฐ›์€ ์•ฑ์˜ ID
return true
}
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
ApplicationDelegate.shared.application( application, didFinishLaunchingWithOptions: launchOptions )//Facebook loing ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋œ ์ฝ”๋“œ
// Override point for customization after application launch.
FBSDKCoreKit.Settings.appID = "์•ฑID"//์•ฑ ID : ํŽ˜์ด์Šค๋ถ ํŽ˜์ด์ง€์—์„œ ๋ฐ›์€ ์•ฑ์˜ ID
return true
}
func facebookLoginBtn()
{ // ๋ฒ„ํŠผ ์ฝ”๋“œ๋กœ ๋“ฑ๋ก
facebook_login_btn.translatesAutoresizingMaskIntoConstraints = false
facebook_login_btn.setTitle("ํŽ˜์ด์Šค๋ถ์œผ๋กœ ๊ณ„์†ํ•˜๊ธฐ", for: .normal)
facebook_login_btn.setTitleColor(.black, for: .normal)
facebook_login_btn.titleLabel?.font = .boldSystemFont(ofSize: 13)
facebook_login_btn.addTarget(self, action: #selector(faceBookLoginButtonAction(_:)), for: .touchUpInside)
facebook_login_btn.layer.cornerRadius = 5
facebook_login_btn.layer.borderWidth = 1
facebook_login_btn.clipsToBounds = true
//๋ณด๋Š” ๊ฒƒ๊ณผ๊ฐ™์ด ์ด๋ฏธ์ง€๋ทฐ์— ํ…Œ๊ทธ๋ฅผ ๋‹ฌ์•„์ฃผ๋Š” ๋ฉ”์„œ๋“œ๋ฅผ ๋งŒ๋“ ๋‹ค.
func imageDragDrop(iv : UIImageView)
{
//์ œ์Šค์ณ ์ด๋ฒคํŠธ๋ฅผ ๋งŒ๋“œ๋Š” ๋ณ€์ˆ˜
let gesture = UIPanGestureRecognizer(target: self, action: #selector(wasRagged(_:)))
//iv ์ด๋ฏธ์ง€ ๋ทฐ์—๋‹ค๊ฐ€ ์ œ์Šค์ณ๋ฅผ ๋„ฃ๋Š” ํ•จ์ˆ˜
iv.addGestureRecognizer(gesture)
//์˜ˆ์‹œ
let uiObject = UIImageView(frame: CGRect(x: 100, y: 200, width: 100, height: 100 ))
// x์ขŒํ‘œ๋กœ 100, y์ขŒํ‘œ๋กœ 200์˜ ์œ„์น˜์— ํฌ๊ธฐ 100, ๋†’์ด 100 ํฌ๊ธฐ์˜ ui์˜ค๋ธŒ์ ํŠธ ์ƒ์„ฑ
//์‚ญ์ œ๋ฐฉ๋ฒ•
uiObejct.removeFromSuperview() //<-ํ•„์ˆ˜
removeFromSuperview()๋ฅผ ํ•„์ˆ˜๋กœ ์ ์šฉ ์‹œ์ผœ์ค˜์•ผ ํ•ฉ๋‹ˆ๋‹ค.