전체 글 (31) 썸네일형 리스트형 Function (함수) 함수 형태 int f(int n) { return n; } int addOne(int n) { return n+1; } // int 는 리턴 타입 // addOne 는 함수 이름 // (int n) 는 매개변수 // return n+1 은 반환 값 void main() { int result = addOne(2); print(“결과: ${result}”); } 익명 함수 (클로저) 함수에 이름이 없습니다. (매개변수) { 동작 혹은 반환값 } // 함수를 매개변수로 전달받을 떄는 Function 키워드를 사용 void magicBox(Function f) { f(); } void main() { //익명 함수를 인수로 전달할 수 있음. magicBox(() { print(“더하기"); } ); } // .. iOS - UINavigationController + UISearchController + UISearchBarDelegate 안녕하세요, 오늘은 저희가 자주사용하는 서치바를 Navigation Item에 추가하는 실습을 해 보겠습니다. 일단 기본적으로 UISearchController 객체를 생성해 줘야 겠죠. 아래와 같은 코드로 생성해 줍니다. let searchController = UISearchController(searchResultsController: nil) 그리고 이제 서치컨트롤러를 navigation controller에 대입해 줘야 하는데요, navigation item이 가지고 있는 searchController 속성을 사용해서 assign 해 줍니다. navigationItem.searchController = searchController 이제 delegate pattern 구현을 위해 UISearch.. iOS - Alamofire Alamofire: URLRequest와 URLSession을 사용하기 편리하도록 만들어 놓은 라이브러리1. 설치: cocoapods를 이용해서 Alamofire설치. 2. 요청(request)만들기 (하나의 메소드로 끝냄.) :Alamofire.request(url:URL, method: 요청방식, parameters: [String:String], encoding: 인코딩방식설정, headers:Header) 헤더에 추가하고 싶은게 있다면 headers에 추가. open API를 찾았는데, 문서에 query(파라미터임). -h 에 있는 부분을 header에 넣음. 예: 인증키(developers.kakao.com에서 검색 api 참고) => method: get, post등 => parameters:.. Swift - Type Casting 안녕하세요, 오늘은 TypeCasting에 대해 알아 보겠습니다. 그 전에 많은 분들이 본인이 작성한 변수에 타입이 어떤건지 확인하고 싶으실 때가 있을텐데요, 이럴때는 아래 is 연산자로 해당 변수에 타입을 확인 할 수 있습니다. A.type check operator 문법: expression is Type is 연산자로 부르기도 함. 이항 연산자임. 형식을 확인할 대상이 왼쪽 표현식에 옴. 오른쪽에는 언제나 형식이 옴. 1.연산 결과는 두 피연산자의 형식이 동일하다면 true. 2.왼쪽피연산자가 오른쪽과 동일한 상속계층이고 오른쪽이 super클래스면 true let num = 123 num is Int // true 중요: 컴파일타임이 아닌 런타임에 타입을 체크 B. type casting opera.. iOS - UIImageView를 활용한 Animation 구현 안녕하세요, 오늘은 UIImageView 를 활용하여 iOS에서 Animation 효과를 구현해 보고자 합니다. 정적 매소드로 UIView의 animate 메소드나 transition animations를 주로 사용하는데요, UIKit은 UIImageView를 여러개 활용하여 애니메이션을 생성하는 API 역시 제공합니다. 오늘은 그 방법을 구현해 보겠습니다. 일단 UIImageView 는 애니메이션 활용을 위해 아래와 같은 속성과 메소드들을 제공합니다. var animationImages: [UIImage]? var highlightedAnimationImages: [UIImage]? var animationDuration: TimeInterval var animationRepeatCount: Int f.. iOS - IBOutlet & IBAction On a Interface builder, hold down the control button and drag & drop to your UIViewController. Then, you will see @IBOulet and @IBAction. When you name your IBAction, try to describe the fact that it was tapped or it pressed. ex: buttonPressed. You can see InterfaceBuilder file on your left and Swift file on your right. Be sure to memorize the following two APIs as they are very useful when you .. iOS - TableView Dynamic Cell Good morning all, I would like to write about table view's dynamic cell today. When you make memo app or to-do app, you might want to sell the entire details of your memo on the memo list. In this case, you could consider write the following codes; import UIKit // Custom Cell Class. I always recommend you to create the UITableViewCell class in a seperate file. class CustomCell: UITableViewCell {.. Source Control with Xcode Today, I would like to write about source control using xcode. In order to use github, you need check "Create Git Repository on my Mac", when you create your xcode project,. Otherwise, local repository will not be installed. Now put some labels or images on your storyboard. Once you have done that, make your second commit. First commit is automatically done when you initiated your project. Move .. 이전 1 2 3 4 다음