youtube url scheme call with native app

 
 let url = NSURL(string: "youtube://www.youtube.com/channel/UC3au7BPB6cch49Uu-bj0UZQ")
            if UIApplication.sharedApplication().canOpenURL(url!)
            {
                // native app
                UIApplication.sharedApplication().openURL(url!)
                print("OK")
            } else {
                // web browser
                let url = NSURL(string: "https://www.youtube.com/channel/UC3au7BPB6cch49Uu-bj0UZQ")
                UIApplication.sharedApplication().openURL(url!)
                print("FALSE")
            }
 





'iPhone > Swift 2.0' 카테고리의 다른 글

swift pageviewcontroller swipe disable 시키기  (0) 2016.04.12
swift NSTimer 타이머  (0) 2016.04.11
swift pull to fresh in tableView or webview  (0) 2016.03.31
swift userDefault  (0) 2016.03.24
Custom table cell 커스텀 테이블뷰  (0) 2016.03.21
블로그 이미지

코딩저장소

,
그냥 별거없고...

두개의 메소드에 리턴 걍nil을 시키면 된다!




'iPhone > Swift 2.0' 카테고리의 다른 글

Swift URL Scheme 호출  (0) 2016.04.27
swift NSTimer 타이머  (0) 2016.04.11
swift pull to fresh in tableView or webview  (0) 2016.03.31
swift userDefault  (0) 2016.03.24
Custom table cell 커스텀 테이블뷰  (0) 2016.03.21
블로그 이미지

코딩저장소

,

'iPhone > Swift 2.0' 카테고리의 다른 글

Swift URL Scheme 호출  (0) 2016.04.27
swift pageviewcontroller swipe disable 시키기  (0) 2016.04.12
swift pull to fresh in tableView or webview  (0) 2016.03.31
swift userDefault  (0) 2016.03.24
Custom table cell 커스텀 테이블뷰  (0) 2016.03.21
블로그 이미지

코딩저장소

,
# WebView

override func viewDidLoad() {
    super.viewDidLoad()
    addPullToRefreshToWebView()
}

func addPullToRefreshToWebView(){
    var refreshController:UIRefreshControl = UIRefreshControl()

    refreshController.bounds = CGRectMake(0, 50, refreshController.bounds.size.width, refreshController.bounds.size.height) // Change position of refresh view
    refreshController.addTarget(self, action: Selector("refreshWebView:"), forControlEvents: UIControlEvents.ValueChanged)
    refreshController.attributedTitle = NSAttributedString(string: "Pull down to refresh...")
    YourWebView.scrollView.addSubview(refreshController)

}

func refreshWebView(refresh:UIRefreshControl){
    YourWebView.reload()
    refresh.endRefreshing()
}




'iPhone > Swift 2.0' 카테고리의 다른 글

swift pageviewcontroller swipe disable 시키기  (0) 2016.04.12
swift NSTimer 타이머  (0) 2016.04.11
swift userDefault  (0) 2016.03.24
Custom table cell 커스텀 테이블뷰  (0) 2016.03.21
App Transport Security 이슈 해결  (0) 2016.03.16
블로그 이미지

코딩저장소

,

swift userDefault

iPhone/Swift 2.0 2016. 3. 24. 10:49

swift userDefault

// save key

NSUserDefaults.standardUserDefaults().setValue("56b40e24e4b0086f384c19b8", forKey: Const.KEY_MEDIA_ID)

NSUserDefaults.standardUserDefaults().synchronize()



// restore key

if let mediaId = NSUserDefaults.standardUserDefaults().valueForKey(Const.KEY_MEDIA_ID) asString { }

'iPhone > Swift 2.0' 카테고리의 다른 글

swift NSTimer 타이머  (0) 2016.04.11
swift pull to fresh in tableView or webview  (0) 2016.03.31
Custom table cell 커스텀 테이블뷰  (0) 2016.03.21
App Transport Security 이슈 해결  (0) 2016.03.16
스위프트 면접 예상문제  (0) 2016.03.15
블로그 이미지

코딩저장소

,

import UIKit

import Alamofire


class ChannelViewController: UIViewControllerUITableViewDataSource, UITableViewDelegate{

    

    @IBOutlet var tableView: UITableView!

    

    var channels:[ChannelField]!

    

    override func viewDidLoad() {

        super.viewDidLoad()


        Alamofire.request(.GET, Const.CHANNEL)

            .responseObject { (response: Response<ChannelVo, NSError>) in

                self.channels = (response.result.value?.result)!;

                self.tableView.delegate = self

                self.tableView.dataSource = self

        }

    }

    

    func numberOfSectionsInTableView(tableView: UITableView) -> Int {

        return 1

    }

    

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        return channels.count

    }

    

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

        let row:ChannelField = channels[indexPath.row]

        

        if let cell = self.tableView.dequeueReusableCellWithIdentifier("ChannelViewCell", forIndexPath: indexPath) as? ChannelViewCell {

            cell.configureCell(row.userThumbnailUrl, titleLabel: row.title, descriptionLabel:row.userName, videoCountLabel:row.mediaCount)

            return cell

        } else {

            return ChannelViewCell()

        }

    }

    

    func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {

        return UITableViewAutomaticDimension

    }

    

    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

        let channel:ChannelField = channels[indexPath.row]

        

        print("MediaID #\(channel.title)!")

        

//        if let rvc = self.storyboard?.instantiateViewControllerWithIdentifier("KYDrawerController") as? KYDrawerController {

//            NSUserDefaults.standardUserDefaults().setValue(section.mediaId, forKey: Const.KEY_MEDIA_ID)

//            NSUserDefaults.standardUserDefaults().synchronize()

//            self.presentViewController(rvc, animated: true, completion: nil)

//        }

        

    }


}










import UIKit

import ImageLoader


class ChannelViewCell: UITableViewCell {


    @IBOutlet var profileImage: UIImageView!

    @IBOutlet var titleLabel: UILabel!

    @IBOutlet var descriptionLabel: UILabel!

    @IBOutlet var videoCountLabel: UILabel!

    

    override func awakeFromNib() {

        super.awakeFromNib()

        // Initialization code

    }


    override func setSelected(selected: Bool, animated: Bool) {

        super.setSelected(selected, animated: animated)


        // Configure the view for the selected state

    }

    

    // init

    func configureCell(profileImage:String, titleLabel:String, descriptionLabel:String, videoCountLabel:String) {

        self.profileImage.load(profileImage)

        self.titleLabel.text = titleLabel

        self.descriptionLabel.text = descriptionLabel

        self.videoCountLabel.text = videoCountLabel

    }

}

'iPhone > Swift 2.0' 카테고리의 다른 글

swift pull to fresh in tableView or webview  (0) 2016.03.31
swift userDefault  (0) 2016.03.24
App Transport Security 이슈 해결  (0) 2016.03.16
스위프트 면접 예상문제  (0) 2016.03.15
swgue를 이용한 데이터 전송  (0) 2016.03.11
블로그 이미지

코딩저장소

,


<key> NSAppTransportSecurity </ key>

<dict>

    <key> NSAllowsArbitraryLoads </ key>

    <true />

</ dict>


위에처럼 추가하면 된다.

'iPhone > Swift 2.0' 카테고리의 다른 글

swift userDefault  (0) 2016.03.24
Custom table cell 커스텀 테이블뷰  (0) 2016.03.21
스위프트 면접 예상문제  (0) 2016.03.15
swgue를 이용한 데이터 전송  (0) 2016.03.11
UIViewController touch event  (0) 2016.03.08
블로그 이미지

코딩저장소

,










@ [UIImage imageNamed] [UIImage initWithContentsOfFile] 차이


imageNamed: imageNamed cache's your images and you lose control over the memory - there's no guarantee that releasing the object will actually release the image but does provide faster loading of images second time around as they are cached. If you are using Interface Builder, and setting the image in Image View Attributes, that is also equal to imageNamed method. The image will be cached immediately when the app is ran


imageWithContentsOfFile : imageWithContentsOfFile does not cache images and is more memory friendly however as it does not cache images and they are loaded much slower. imageWithContentsOfFile: requires you to put the full path. I don't see why imageNamed: wouldn't be recommended, besides the fact that you can't access files outside of the application bundle.


:> 인터페이스 빌더에 UIImageView 추가하고 이미지 파일을 설정하게 되면 내부적으로 imageNamed 사용




@ 개인프로젝트와 스토어 경험( 리젝사유:격었던 문제와 해결했던 방법에 대한 얘기)


@ 디버깅은 어떤식으로 주로 하나? 디버거사용 or print 사용


@ 멀티랭귀지 다국어경험 여부


@가로모드 대응 해본 경험이 있는가?(오토레이아웃으로 했는가, 디바이스별로 대응했는가?)


@ cocoapods 사용하나? 주로 어떤 사이브러리 사용하는가? alamofire사용해봤나? 모델은 어떻게 생성해보았는가?


* swift 경험

@ swift vs objc 어떤걸 선호?


@ swift extension 사용경험


@ Firebase들어보았는가? 관심갔던 부분은 어디인가?


@ protocol 사용경험. 언제 사용해봤나?


@ swift공부는 어디서 하나? 최신 트랜드는 어디서?


@ swift 2.0으로 공부했나?

 - 3.0에서 사용하지 말아야 할것은

#selector(test), c style for loop


@ Closure 익명함수?  

  - Functional Language 에서의 함수는 OOP 에서의 객체와 동일하다고 보시면 됩니다

  - 코드는 이전 강좌(04)에서 설명했기 때문에 생략하겠습니다


  1) 함수내에서 함수를 정의할 있습니다

  2) 함수의 인자로 함수를 받을 있습니다

  3) 함수의 리턴값으로 함수를 넘길 있습니다

  4) 변수에 함수를 입력할 있습니다 ( 말은 함수도 하나의 객체로써 포인터를 가진다는 의미입니다)



------------

제일많이 화냈던적?

10년뒤 5년뒤 뭐할것 같나?

과에 몇명이였고 몇등정도 했었나?

잘짜여진 코드란 무엇이라고 생각하는가?

신규 vs 유지보수 당신의 스타일은?


블로그 이미지

코딩저장소

,

보내는 컨트롤러   

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        if segue.identifier == "ShowDescriptionSegue" {

            if let destinationVC = segue.destinationViewController as? VideoDescriptionController {

                destinationVC.myDescription = result.sceneTitleTimeInfo

            }

        }

    }



받는 컨트롤러

    var myDescription:String = ""


    

    override func viewWillAppear(animated: Bool) {

        super.viewWillAppear(animated)

        descriptions.text = myDescription

    }

블로그 이미지

코딩저장소

,
class YourView: UIView {

  //Define your initialisers here

  override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
    if let touch = touches.first as? UITouch {
      let currentPoint = touch.locationInView(self)
      // do something with your currentPoint
    }
  }

  override func touchesMoved(touches: Set<NSObject>, withEvent event: UIEvent) {
    if let touch = touches.first as? UITouch {
      let currentPoint = touch.locationInView(self)
      // do something with your currentPoint
    }
  }

  override func touchesEnded(touches: Set<NSObject>, withEvent event: UIEvent) {
    if let touch = touches.first as? UITouch {
      let currentPoint = touch.locationInView(self)
      // do something with your currentPoint
    }
  }
}


블로그 이미지

코딩저장소

,