Victor Choi

  • Home
  • Business
    • Internet
    • Market
    • Stock
  • Parent Category
    • Child Category 1
      • Sub Child Category 1
      • Sub Child Category 2
      • Sub Child Category 3
    • Child Category 2
    • Child Category 3
    • Child Category 4
  • Featured
  • Health
    • Childcare
    • Doctors
  • Home
  • Business
    • Internet
    • Market
    • Stock
  • Downloads
    • Dvd
    • Games
    • Software
      • Office
  • Parent Category
    • Child Category 1
      • Sub Child Category 1
      • Sub Child Category 2
      • Sub Child Category 3
    • Child Category 2
    • Child Category 3
    • Child Category 4
  • Featured
  • Health
    • Childcare
    • Doctors
  • Uncategorized

12/05/2017

A Code Sample to use Core Data Stack as a Singleton

 6:26 PM     AppDelegate, Core Data, Core Data to Singleton, Singleton     No comments   

I used to create an instance of my Core Data Stack in AppDelegate file and accessed it from other View Controllers. But I have to modify it because iOS 11 forces to access AppDelegate file in the main thread. So I made my Core Data Stack as a singleton.

If you are looking for a code sample to make your core data stack as a singleton. Please refer the code below.

class func sharedInstance() -> CoreDataStack {
    struct Static {
        static let instance = CoreDataStack()
    }
    return Static.instance
}
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg

How can I detect iPhone X's screen size?

 4:32 PM     Detect iPhone X Screen, iPhone X, iPhone X Screen Size, UIScreen     No comments   

How can I detect iPhone X’s screen size?

After Apple released iPhone X I am trying to update my application for iPhone X. The UI elements to fit iPhone X I have to detect the screen size of iPhone X and I found the code below which works for me.

if UIDevice().userInterfaceIdiom == .phone {
        switch UIScreen.main.nativeBounds.height {
        case 1136:
            print("iPhone 5 or 5S or 5C")
        case 1334:
            print("iPhone 6/6S/7/8")
        case 2208:
            print("iPhone 6+/6S+/7+/8+")
        case 2436:
            print("iPhone X")
        default:
            print("unknown")
        }
    }
  • source
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Posts Older Posts Home

Search This Blog

Popular Posts

  • How to put a padding into a UITextField ?
  • Keynote Tutorial Text Outline - Make your animation meaningful
  • Keynote Tutorial , Sound is a design,too
  • Keynote Tutorial How to improve your bullets

Blog Archive

  • ►  2020 (2)
    • ►  January (2)
  • ►  2019 (21)
    • ►  December (2)
    • ►  November (6)
    • ►  October (5)
    • ►  September (2)
    • ►  August (3)
    • ►  July (2)
    • ►  June (1)
  • ▼  2017 (11)
    • ▼  December (2)
      • A Code Sample to use Core Data Stack as a Singleton
      • How can I detect iPhone X's screen size?
    • ►  November (2)
    • ►  July (2)
    • ►  May (1)
    • ►  April (1)
    • ►  March (3)
  • ►  2016 (48)
    • ►  December (3)
    • ►  November (2)
    • ►  September (1)
    • ►  August (10)
    • ►  July (5)
    • ►  June (7)
    • ►  May (2)
    • ►  April (18)
Powered by Blogger.

Navigation Menu

  • Home
  • About
  • Documentation
  • Contact

Contact Us

Name

Email *

Message *

Copyright © Victor Choi | Powered by Blogger
Design by Hardeep Asrani | Blogger Theme by NewBloggerThemes.com | Distributed By Gooyaabi Templates