SWIFT (18) 썸네일형 리스트형 xcode에 swift realm 적용하기 (swift 2.2 기준) 우선 Realm 사이트에서 소스를 다운받는다: https://realm.io/docs/swift/latest/아래의 순서대로 설정하면 된다. 그런데 나 같은 초짜는 이것도 하기 힘들다.한글 사이트는 이 글을 쓰는 시점에서 2.2에 대한 해석은 되어 있지 않았다. Download the latest release of Realm and extract the zip.Go to your Xcode project’s “General” settings. DragRealmSwift.framework and Realm.framework from the ios/swift-2.2/,watchos/, tvos/ or osx/swift-2.2/ directory to the “Embedded Binaries” section.. 스위프트에서 기본 제공하는 폰트들 fonts in swift 다음과 같은 코드로 목록을 얻을 수 있다. func printFonts() { for familyName in UIFont.familyNames() { print("familyName=\(familyName)") for fontname in UIFont.fontNamesForFamilyName(familyName) { print("fontname=\(fontname)") } } } familyName=Thonburifontname=Thonburi-Boldfontname=Thonburifontname=Thonburi-LightfamilyName=Khmer Sangam MNfontname=KhmerSangamMNfamilyName=Kohinoor Telugufontname=KohinoorTelugu-Regu.. selector in swift selector 사용법이 좀 바뀌었는데 예전 사용법이 너무 많이 검색된다.문자열을 메소드로 인식시키는 예전 방법이 error 유발 가능성은 더 크지만 유연한 사용법을 제시할 수 있어 더 좋았던 것 같다.지금은 이런 식으로 사용하려면 어찌해야 하는지.. 역시 스위프트 공홈에서 퍼왔다. In Swift 2.1, code like the below would compile with no problems:override func viewDidLoad() { super.viewDidLoad() navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "addNewFireflyRefernce".. for loop in swift 스위프트의 for 구문 : 역순 루프도 참고하시라.스위프트 공식 홈피에 있는 글인데 검색이 잘 안 되서리 퍼왔다. Even though Swift has several idiomatic loop options, C-style for loops were still part of the language and occasionally used. For example:for var i = 0; i 스위프트에서 CFDictionary 사용하기 사실 아직도 이해하고 있지 못 하는 코드이기도 하다. Objective-C에서는 단 2~3줄 코딩으로 해결되는 것을 스위프트에서는 왜 이렇게 코딩하는 것인지 모르겠다. (물론 내가 다른 값을 추가하긴 했지만..) /* NSDictionary *options = @{(id)kCVPixelBufferCGImageCompatibilityKey: @YES, (id)kCVPixelBufferCGBitmapContextCompatibilityKey: @YES}; */ // stupid CFDictionary stuff let cfnumPointer = UnsafeMutablePointer.alloc(1) let cfnum = CFNumberCreate(kCFAllocatorDefault, .IntType, cfnu.. Swift에서 포인터에 메모리 할당하기 스위프트에서 포인터를 사용하게 되면 메모리를 할당해주어야 나중에 실행시켜보면 오류가 나지 않는다. 아직 포인터 개념이 좀 약해서 선언 후 이짓저짓 다 해 보았지만 결론은 큰 차이가 없어서 기록을 남긴다. let pxbuffer = UnsafeMutablePointer.alloc(1) // if pxbuffer = nil, you will get status = -6661 처음에 참고한 코드는 nil을 넣으라고 했는데 리턴값이 6661 오류가 발생하였다.다음으로 찾아낸 코드는 .alloc(1)을 해주었는데 이대로 해 보니 오류는 발생하지 않았다. 하지만 다른 데서 오류가 났었기 때문에 이 부분을 신경 쓸 겨를이 없었다. 나중에 오류가 나지 않는 코드를 완성한 후 1 이외에도 다른 값들을 넣어 보았다. le.. To understand pixelBufferFromCGImage with Swift I have 2 problems. one is black screen and another is abnormal pxbuffer image. black screen problem is because Changing UIImage to CGImage. abnormal pxbuffer image problem is below.left one is abnormal pxbuffer image, right one is source image. The cause was bytesPerRow.I tested an image with 100px image. but pxbuffer's bytesPerRow was 448. So I solved like below. (source: https://github.com/seo.. Swift: Convert between CGImage, CIImage and UIImage Swift에서 이미지 종류별로 변환하는 방법이 명쾌하게 설명된 사이트를 찾아서 여기에 기록한다. 출처: http://wiki.hawkguide.com/wiki/Swift:_Convert_between_CGImage,_CIImage_and_UIImage 사실 나는 이 자료를 UIImage를 CGImage로 변환하기 위해서 찾아왔는데 변환 방법이 간단하지 않아서 놀랐다.Swift: Convert CIImage to CGImage?1234567func convertCIImageToCGImage(inputImage: CIImage) -> CGImage! { let context = CIContext(options: nil) if context != nil { return context.createCGImage(.. 이전 1 2 3 다음