Entity Classes in Swift

We must admit that most of use MVC pattern when it comes to business kinda apps or any type of apps at all. And before developing on Ios i used entity classes with C#, Java, Python you name it, and i want to write an example of them in Swift let’s begin. Define a new Swift file I generally store my entity classes in a different folder like, Model or Entities....

2 min · Ahmet Gokdayi

Swift Add UIViews programmatically

Recently, when i was working on a Swift project on Xcode, i added UITabBarController and run the project. When i opened back my storyboard, it was just gone. It threw an error, i tried to figure it out, tested some of the recommended fixes on google, but it could not be solved. Now, i’m 100% implementing my view controllers programmatically. Add a basic UIView I assume that you have just opened a new project and you have your ViewController....

3 min · Ahmet Gokdayi

Swift Anchoring UIScrollViews using NSLayoutAnchor

I’ve been using NSLayoutAnchor class to define constraints on my UIView controls. But when working with UIScrollView i got stuck. It was not scrolling down or up as i add new subViews in it. As it turns out, you need to calculate the spacing between the elements in scrollView, yourself. Top Anchor must be set to ScrollViews' I have a container UIView controller and it’s constraints are set to the safeArea like this:...

2 min · Ahmet Gokdayi

Swift Layout Constraints Basics

Making your apps look good on any dimension is not quite easy on all platforms, but when developing on xcode, Apple made it easy to make them look fit on any screen size. You achieve this by using constraints. Open up your storyboard and i assume that you got a few elements on your view and lets a background image. Make background fit on all sizes Your background image should already be in the full-size of the screen, and after doing that, click on the little button right at the bottom of the pane (The 2nd button from the right....

2 min · Ahmet Gokdayi

Swift Show Alert to User

Say that I needed an alert for my app to let the user that my app has some mistakes or you i wanted to user to select some options before moving on, in cases like these you may wanna show a messageBox like alert using the UIAlertController class, let’s begin Initialize class instance First of all we need an object created from this class: var alert : UIAlertController = UIAlertController(title: "Somethings happening", message: "Whadaya wanna do?...

2 min · Ahmet Gokdayi