Skip to content

Instantly share code, notes, and snippets.

View AppleCEO's full-sized avatar
๐Ÿ’ป

๋„๋ฏธ๋‹‰ AppleCEO

๐Ÿ’ป
View GitHub Profile
class ParentViewController: UIViewController {
let button: UIButton()
...
func onTapButton() {
let popupVC = PopupViewController()
popupVC.onDoneBlock = { [weak self] in
self?.moveToNextView()
}
}
@groz
groz / sync-http.swift
Created February 15, 2018 22:29
Synchronous http request in Swift
import Foundation
func query(address: String) -> String {
let url = URL(string: address)
let semaphore = DispatchSemaphore(value: 0)
var result: String = ""
let task = URLSession.shared.dataTask(with: url!) {(data, response, error) in
result = String(data: data!, encoding: String.Encoding.utf8)!
@godrm
godrm / swift_api_guideline.md
Last active February 20, 2025 11:30
์Šค์œ„ํ”„ํŠธ API ๊ฐ€์ด๋“œ๋ผ์ธ

1. ์Šคํƒ€์ผ/๋ฌธ๋ฒ• ๋ฆฌ๋ทฐ

1-1 ์Šค์œ„ํ”„ํŠธ API ๋””์ž์ธ ๊ฐ€์ด๋“œ๋ผ์ธ

https://swift.org/documentation/api-design-guidelines/

  • ์‚ฌ์šฉํ•  ๋•Œ ๊ธฐ์ค€์œผ๋กœ ๋ช…ํ™•ํ•˜๊ฒŒ ์ž‘์„ฑํ•˜๋Š” ๊ฒŒ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ์ง€ํ–ฅ์ ์ด๋‹ค. ๋ฉ”์†Œ๋“œ๋‚˜ ํ”„๋กœํผํ‹ฐ ๊ฐ™์€ ๊ฐœ๋ฐœ ์š”์†Œ๋Š” ํ•œ ๋ฒˆ๋งŒ ์„ ์–ธํ•˜๊ณ  ๋ฐ˜๋ณต์ ์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. API๋ฅผ ๋งŒ๋“ค ๋•Œ๋Š” ์‚ฌ์šฉํ•˜๊ธฐ ๋ช…ํ™•ํ•˜๊ณ  ํŽธํ•˜๊ฒŒ ๋งŒ๋“ค์–ด์•ผ ํ•œ๋‹ค. ์„ค๊ณ„๋ฅผ ๊ฒ€์ฆํ•  ๋•Œ ์„ ์–ธ ๋ถ€๋ถ„์„ ์ฝ๋Š” ๊ฒƒ๋งŒ์œผ๋กœ๋Š” ๋ถ€์กฑํ•˜๋‹ค. ๊ทธ ๋Œ€์‹  ์‚ฌ์šฉํ•˜๋Š” ์ƒํ™ฉ์—์„œ ๋งฅ๋ฝ์— ๋งž๊ณ  ๋ช…ํ™•ํ•œ ์ง€ ๋Š˜ ๊ณ ๋ คํ•ด์•ผ ํ•œ๋‹ค.

  • ๋ช…ํ™•ํ•œ ํ‘œํ˜„์ด ์••์ถ•ํ•œ ๊ฐ„๊ฒฐ์„ฑ๋ณด๋‹ค ๋” ์ค‘์š”ํ•˜๋‹ค. ์Šค์œ„ํ”„ํŠธ ์ฝ”๋“œ๋Š” ์••์ถ•ํ•ด์„œ ๊ฐ„๊ฒฐํ•˜๊ฒŒ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ๋‹จ์ง€ ๊ธ€์ž์ˆ˜๋ฅผ ์ค„์—ฌ์„œ ๊ฐ€์žฅ ์งง์€ ์ฝ”๋“œ๋ฅผ ๋งŒ๋“œ๋Š” ๊ฒŒ ๋ชฉํ‘œ๋Š” ์•„๋‹ˆ๋‹ค. ์Šค์œ„ํ”„ํŠธ ์ฝ”๋“œ์˜ ๊ฐ„๊ฒฐ์„ฑ์€ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋ฐ˜๋ณต์ ์œผ๋กœ ์žฌ์‚ฌ์šฉํ•˜๋Š” ์ฝ”๋“œ(boilerplate)๋ฅผ ์ค„์ด๋Š” ๊ธฐ๋Šฅ๊ณผ ๊ฐ•ํ•œ ํƒ€์ž… ์‹œ์Šคํ…œ์˜ ๋ถ€์ˆ˜ํšจ๊ณผ๋กœ ๋“œ๋Ÿฌ๋‚  ๋ฟ์ด๋‹ค.

@480
480 / gist:4681b67d2a906db8c6c1321cc678f05f
Last active June 2, 2025 00:23
github ๋ฆฌ๋ชจํŠธ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ๋ณ€๊ฒฝํ•˜๊ธฐ

๊นƒ ๋ฆฌ๋ชจํŠธ ๋ณ€๊ฒฝ ํ•˜๊ธฐ

๊ธฐ์กด ๋ฆฌํฌ์ง€ํ† ๋ฆฌ ๊น”๋”ํ•˜๊ฒŒ pull / push

git pull
git add .
git commit -m "clean push"
git push
@AlexHedley
AlexHedley / Parse JWT.m
Last active April 6, 2021 02:14
Parse a JWT - JSON Web Token
//DECODE JSON WEB TOKEN (JWT) IN IOS (OBJECTIVE-C)
//http://popdevelop.com/2013/12/decode-json-web-token-jwt-in-ios-objective-c/
NSString *jwt = @"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIifQ.bVhBeMrW5g33Vi4FLSLn7aqcmAiupmmw-AY17YxCYLI";
NSArray *segments = [jwt componentsSeparatedByString:@"."];
NSString *base64String = [segments objectAtIndex: 1];
NSLog(@"%@", base64String);
// => "eyJmb28iOiJiYXIifQ"
@maciekish
maciekish / resetXcode.sh
Created August 10, 2016 10:13
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches. You can thank me later.
#!/bin/bash
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
open /Applications/Xcode.app
@jooyunghan
jooyunghan / monad-in-java.md
Last active November 17, 2023 04:54
ํ•œ๊ธ€๋ฒˆ์—ญ - Functor and monad examples in plain Java

Functor and monad examples in plain Java

์ด ๊ธ€์€ ์šฐ๋ฆฌ๊ฐ€ ์“ด ์ฑ…, 'Reactive Programming with RxJava' ์˜ ๋ถ€๋ก์ด์—ˆ๋‹ค. Reactive programming๊ณผ ๊ด€๋ จ์ด ๊นŠ์€ ์ฃผ์ œ๊ธด ํ•˜์ง€๋งŒ ๋ชจ๋‚˜๋“œ๋ฅผ ์†Œ๊ฐœํ•œ๋‹ค๋Š” ๊ฒŒ ์ฑ…๊ณผ ์ฉ ์–ด์šธ๋ฆฌ์ง€๋Š” ์•Š์•˜๋‹ค. ๊ทธ๋ž˜์„œ ๋‚˜๋Š” ๋”ฐ๋กœ ๋ธ”๋กœ๊ทธ์— ์˜ฌ๋ฆฌ๊ธฐ๋กœ ํ–ˆ๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ๋‹ค๋ฃจ๋Š” ๋ธ”๋กœ๊ทธ์—์„œ *"๋ฐ˜์€ ๋งž๊ณ  ๋ฐ˜์€ ํ‹€๋ฆด ์ง€ ๋ชจ๋ฅด๋Š” ๋‚˜๋งŒ์˜ ๋ชจ๋‚˜๋“œ ์„ค๋ช…"*์ด๋ž€ ๊ฒƒ์ด ์ƒˆ๋กœ์šด *"Hello World"*๋ผ๋Š” ์ ์„ ๋‚˜๋„ ์ž˜ ์•ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ด ๊ธ€์€ ํŽ‘ํ„ฐ(functor)์™€ ๋ชจ๋‚˜๋“œ(monad)๋ฅผ ์ž๋ฐ” ์ž๋ฃŒ ๊ตฌ์กฐ์™€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ผ๋Š” ๊ฐ๋„์—์„œ ๋ฐ”๋ผ๋ณด๊ณ  ์žˆ์œผ๋ฉฐ, ์ด๋Š” ๊ณต์œ ํ•  ์ •๋„์˜ ๊ฐ€์น˜๋Š” ์žˆ์„๊ฑฐ๋ผ ์ƒ๊ฐํ–ˆ๋‹ค.

@goodmorningcody
goodmorningcody / ViewController.swift
Last active March 3, 2020 07:12
์Šค์œ„ํ”„ํŠธ : ์œ„์น˜์ •๋ณด ์‚ฌ์šฉ ๊ถŒํ•œ์— ๋”ฐ๋ฅธ ์˜ˆ์™ธ์ฒ˜๋ฆฌ ์ถ”๊ฐ€ํ•˜๊ธฐ
import UIKit
import CoreLocation
class ViewController: UIViewController, CLLocationManagerDelegate {
// ์ค‘๋žต
@IBOutlet var requestWeatherButton : UIButton!
override func viewDidAppear(animated: Bool) {