Skip to content

Instantly share code, notes, and snippets.

View ivangodfather's full-sized avatar
🍂

Ivan Ruiz ivangodfather

🍂
View GitHub Profile
var arr = [NSURL]()
for urlString in urlsStrings {
if let url = NSURL(string: urlString) {
arr.append(url)
}
}
return arr
class GameScore {
static let sharedInstance = GameScore()
var score: Int = 0
func incrementScore() -> Int {
return score++
}
private init() { }
}
println(GameScore.sharedInstance.incrementScore())
This entries in infite loop loading the childVC (this VC)
override func didMoveToParentViewController(parent: UIViewController?) {
super.didMoveToParentViewController(parent)
if let parentVC = parent as? BannersVC {
parentVC.performSegueWithIdentifier("root", sender: self)
}
}
This is doing the segue correctly
override func didMoveToParentViewController(parent: UIViewController?) {
super.didMoveToParentViewController(parent)
if let parentVC = parentViewController as? BannersVC {
parentVC.performSegueWithIdentifier("root", sender: self)
}
}
override func didMoveToParentViewController(parent: UIViewController?) {
super.didMoveToParentViewController(parent)
if let parentVC = parentViewController as? BannersVC {
parentVC.performSegueWithIdentifier("root", sender: parentVC)
}
}
var bannerPagerVC = BannerPagerVC(transitionStyle: .Scroll, navigationOrientation: .Horizontal, options: [UIPageViewControllerOptio nInterPageSpacingKey: interPageSpacing])
bannerPagerVC.view.frame = bannerContainer.pagerView.bounds
bannerContainer.pagerView.addSubview(bannerPagerVC.view)
addChildViewController(bannerPagerVC)
bannerPagerVC.didMoveToParentViewController(self)
class BannerPagerVC: UIPageViewController {
override func viewDidLoad() {
super.viewDidLoad()
protocol SharedProperties {
var columns: Int { get }
}
class BaseClass {
var test: Int = 4
struct Properties: SharedProperties {
var columns: Int { 4 }
var name: String { "Testing" }
let shopVC = ShoppingCardVC(nibName:"ShoppingCardVC", bundle:nil)
let bundle = NSBundle(forClass: self.dynamicType)
let nib = UINib(nibName: "ShoppingCardVC", bundle: nil)
let customView = nib.instantiateWithOwner(shopVC, options: nil).first! as UIView
bottomView.addSubview(customView)
shopVC.didMoveToParentViewController(self)
let shopVC = ShoppingCardVC()
let shopView = NSBundle.mainBundle().loadNibNamed("ShoppingCardVC", owner: shopVC, options: nil).first! as UIView
shopView.frame = bottomView.bounds
bottomView.addSubview(shopView)
shopVC.didMoveToParentViewController(self)
class MyClass {
override func viewDidLoad() {
let newVC = ShoppingCardVC(nibName: "NewVC", bundle: nil)
bottomView.addSubview(newVC.view)
newVC.didMoveToParentViewController(self)
}
}
class NewVC { // In NewVC.xib i have a button with an action poiting here
@IBAction func test(sender: AnyObject) {