일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- PER
- 날짜
- sqlite
- MySQL
- javascript
- ASP
- swift
- flutter
- python
- 라즈베리파이
- tensorflow
- port
- GIT
- Excel
- 리눅스
- 맛집
- urllib
- Unity
- IOS
- mssql
- PyQt5
- 함수
- 다이어트
- 유니티
- PyQt
- MS-SQL
- ubuntu
- Linux
- pandas
- node.js
목록swift (48)
아미(아름다운미소)
스위프트(Swift)로 코딩을 하며 iOS어플 개발을 하다보면 HTTP연결이 제한되는 경우가 있습니다.iOS9부터 HTTP가 아닌 HTTPS로의 접근만 허용해놨기 때문인데요. info.plist파일의 HTTP 연결 권한을 줘야 정상적으로 통신이 가능합니다. - 모든사이트 오픈 NSAppTransportSecurity NSAllowsArbitraryLoads - 해당사이트만 오픈 NSAppTransportSecurity NSExceptionDomains yourserver.com NSExceptionAllowsInsecureHTTPLoads
가끔 숫자값을 3자리 단위로 콤마(,)를 추가하여 자릿수를 구분해주는 기능이 필요할 경우 extension Int { var withComma: String { let decimalFormatter = NumberFormatter() decimalFormatter.numberStyle = NumberFormatter.Style.decimal decimalFormatter.groupingSeparator = "," decimalFormatter.groupingSize = 3 return decimalFormatter.string(from: self as NSNumber)! } } extension String { var delComma: String { if self.characters.count > 0 ..
코드로 정의하기 스토리보드를 이용하지 않고 코드상으로 연결하는 방법입니다. @IBAction private func playBtn(_ sender: UIButton) { let vc = self.storyboard?.instantiateViewController (withIdentifier: "Resultsidentifer") as! ResultsViewController vc.userChoice = getUserShape(sender) present(vc, animated: true, completion: nil) } withIdentifier의 "Resultsidentifer" 부분은 두 번째 view controller의 identifer이고 그 뒤 ResultsViewController는 clas..
- Swift 2 func convertStringToDictionary(text: String) -> [String:AnyObject]? { if let data = text.dataUsingEncoding(NSUTF8StringEncoding) { do { return try NSJSONSerialization.JSONObjectWithData(data, options: []) as? [String:AnyObject] } catch let error as NSError { print(error) } } return nil } let str = "{\"name\":\"James\"}" let result = convertStringToDictionary(str) - Swift 3 func convert..
페이지 컨트롤페이지 컨트롤(Page Control)은 여러 페이지 중에서 현재 페이지를 알려 주는 역활을 합니다.현재 뷰에서 보여 주려는 내용이 여러 개일 때 사용합니다. 갤러리나 아이폰 홈 화면과 같은 앱에서 전체 페이지 중 현재 페이지가 어느 부분에 있는지 알려 줄 때 사용합니다. 위치 뷰 컨트롤러의 클래스 선언문 바로 아래 연결(Connection) Outlet 이름(Name) imgView 유형(Type) UIImageView 위치 imgView 아웃렛 변수 아래 연결(Connection) Outlet 이름(Name) pageControl유형(Type) UIPageControl 위치 뷰컨트롤러 클래스 맨 아래 연결(Connection) Action 이름(Name) pageChanged유형(Type..
위치와 경도로 원하는 핀 설치하기 위치 마지막줄 연결(Connection) Action 이름(Name) sgChangeLocation 유형(Type) UISegmentedControl [전체소스] import UIKitimport MapKit class ViewController: UIViewController, CLLocationManagerDelegate{ @IBOutlet weak var myMap: MKMapView! @IBOutlet weak var lblLocationInfo1: UILabel! @IBOutlet weak var lblLocationInfo2: UILabel! let locationManager = CLLocationManager() override func viewDidLoa..
- 위치 정보를 추출해서 텍스트로 표시하기 위치 myMap 아웃렛 변수 바로 아래 연결(Connection) Outlet 이름(Name) lblLocationInfo1 유형(Type) UILabel 위치 lblLocationInfo1 아웃렛 변수 바로 아래 연결(Connection) Outlet 이름(Name) lblLocationInfo2 유형(Type) UILabel [해당소스] @IBOutlet weak var lblLocationInfo1: UILabel! @IBOutlet weak var lblLocationInfo2: UILabel! CLGeocoder().reverseGeocodeLocation(pLocation!, completionHandler: { (placemarks, error) -..
위도와 경도로 원하는 위치 표시하기 [해당 소스] func goLocation(latitude latitudeValue: CLLocationDegrees, longitude longitudeValue : CLLocationDegrees, delta span :Double) { //위도 값과 경도 값을 매개변수로 하여 CLLocationCoordinate2DMake 함수를 호출하고, 리턴값을 pLocation로 받습니다. let pLocation = CLLocationCoordinate2DMake(latitudeValue, longitudeValue) //범위 값을 매개변수로 하여 MKCoordinateSpanMake함수를 호출하고, 리턴 값을 spanValue로 받습니다. let spanValue = M..
- Map Kit View 추가 후 아웃렛 변수 설정 위치 class ViewController 최상단 연결(Connection) Outlet 이름(Name) myMap 유형(Type) MKMapView import MapKit @IBOutlet weak var myMap: MKMapView! - Info.plist(수정) : 앱이 사용자 위치에 접근하도록 허용하기 import UIKitimport MapKit class ViewController: UIViewController, CLLocationManagerDelegate{ @IBOutlet weak var myMap: MKMapView! let locationManager = CLLocationManager() override func viewDi..
- 웹 뷰로 간단한 웹 브라우져 만들기 7프로토콜이 있는지를 검사하고 없을 경우 'http://' 문자열을 자동으로 추가하는 함수를 만들어 보겠습니다. func checkUrl(_ url: String) -> String { //입력받은 url스트링을 임시 변수 strUrl에 넣습니다. var strUrl = url //"http://"를 가지고 있는지 확인한 값을 flag에 넣습니다. let flag = strUrl.hasPrefix("http://") //"http://"를 가지고 있지 않다면, 즉 '!flag'일 때 변수 strUrl에 "http://"를 추가하고 이를 리턴합니다. if !flag { strUrl = "http://" + strUrl } return strUrl } @IBAction..