-
Simulating remote push notifications in a simulator
Feb 13, 2020 • Push Notifications • swift, ios simulator, simulator notifications
Apple just released Xcode 11.4 beta with tons of features. One of the notable features is simulating remote push notifications in simulators, which means that triggering remote notifications in simulators is now possible.
-
Why should we avoid using closures in Swift structs?
Jan 9, 2020 • Closures • swift, struct, closures, struct vs classes
We all love closures, don’t we? Closures make an iOS developer’s life easy. Well, if it makes it easy, then why am I saying to avoid using closures in Swift structs? The reason is, “Memory leaks and unexpected behaviors.” Wait. What? Memory leak in structs? How could that be possible?
-
Swift 5 replaces IntroSort with TimSort in the 'sort()' method
Sep 29, 2019 • Algorithms • swift, timsort, algorithms, sort
When we hear the term ‘Sorting,’ the algorithms which come to our mind are quicksort, insertion sort, merge sort, bubble sort, heap sort, and other sorting algorithms. We would have used the method
sort()
to sort elements in an array, in our day to day programming tasks. However, have you ever wondered what algorithm does the method uses to sort the items in Swift? Before Swift 5, it was ‘Introsort,’ but after Swift 5, it is ‘Timsort.’ Timsort is a sorting algorithm, used in programming languages like Python, and Java. I am going to cover mostly about ‘Timsort’ in this article. -
Generate URLSession code in Swift using Postman
Almost every iOS developer would have had to make a network call from their app. Swift uses URLSession to make network calls. URLSessionTask includes DataTask, UploadTask, DownloadTask, and WebsocketTask (WebsocketTask is lately introduced in iOS13.0 check this article to know more about it.) I was testing a multipart data request API using the [Postman app.]https://www.getpostman.com/ The API worked, the file got uploaded, and the results came in. However, I needed to write the Swift code to make a multipart request from the iOS app. Writing code for data task can be simple, but the complexity increases when we write code for multipart requests. I was wondering whether Postman can generate the multipart data request code for me, turns out that it could!
-
Introducing URLSessionWebSocketTask - Native WebSocket implementation using Swift 5
Aug 31, 2019 • URLSession • swift, iOS, websockets, URLSessionWebSocketTask
We all love WebSockets, don’t we? They have a vast range of applications such as chat applications, push notifications, and much more. I got excited when I stumbled upon “URLSessionWebSocketTask”. That’s right, in addition to data task, download task, and upload task, we have websocketTask! in URLSession. Websockets are now first-class citizens in the foundation framework. Before websocket tasks, we had to use third-party libraries like Star Scream or Socket Rocket, but it is not the case anymore.
-
Swift bit #4 - Swifty ways of typecasting objects
Aug 26, 2019 • Swift fundamentals • swift, iOS, type casting
Often we find ourselves in a situation where we need to check whether an object belongs to a particular class or not. For example, consider there is a UIView, and there are many subviews like UITextView, UILabel, and UIStepper. Now you have to find the UILabel from the parent view and change its text value. So how do we do that? Well, there are multiple ways of doing it.
-
Enabling 'Sign in with Apple'in developer account
Aug 11, 2019 • Sign in with Apple • swift, iOS, Sign in with Apple
‘Sign in with Apple’ is an exciting feature announced in WWDC 2019. You must be wondering how to get started. Well, this article is about completed the configuration, Click here to know how to integrate ‘Sign in with Apple’ feature in your iOS apps.
-
Integrating 'Sign in with Apple' in iOS apps
Aug 4, 2019 • Sign in with Apple • swift, iOS, Sign in with Apple
The WWDC 2019 gave us many features to look forward. One of the most exciting features and my favorite is the ‘Sign In with Apple’ feature in iOS 13. The users can sign in securely, and their privacy is guaranteed. Apple is holding up their biggest promise of privacy with this feature. It is available for web and other platforms as well. We will be exploring and learning the integration of ‘Sign In with Apple’ on different platforms in the upcoming articles. Now, let us get started with how we can integrate it into our iOS app.
-
Swift bit #3 — Unwrap optional values using for in loop
Aug 2, 2019 • Swift fundamentals • swift, for loops, for in loops, unwrap, optionals
One of the most widely used features in Swift are the optionals. Optionals are types that can hold either a value or a nil value i.e nil.
-
Swift bit #2 - Using Booleans the right way, in Swift
Aug 2, 2019 • Swift, fundamentals • swift, booleans
Boolean is one of the most frequently used and simplest data type in any programming language.It is common to want to toggle the state of the boolean variable. So, we normally do it like this,
-
Swift bit #1 — Using “where” clause in “for in” loops
Aug 1, 2019 • Swift fundamentals • swift, for loops, for in loops, unwrap, optionals
We all would have written a piece of code similar to this, The usual way,
-
Humble beginnings
Jul 31, 2019 • Personal
Blogging has always been my favorite exercise. I started creating websites using Wordpress, PHP, and PHPBB nearly ten years back. After a point, I took the path of iOS development. I became an iOS developer. Learning things in iOS was challenging as well as it was fun at the same time. As I discovered new things, I thought, why shouldn’t I share my knowledge with other fellow developers? And this is the reason why I have started the blog. So much has evolved since then. With the introduction of new technologies and frameworks, there are so many ways to set up a website. The challenge is to select the right technology for the intended purpose. After doing in-depth research, I made up my mind to set up a blog using Jekyll. Yes, Jekyll powers ohmyswift.com. Thanks to the developer community, which helped me in choosing the right framework to set up my blog.
-
Simulating remote push notifications in a simulator
Apple just released Xcode 11.4 beta with tons of features. One of the notable features is simulating remote push notifications in simulators, which means that triggering remote notifications in simulators is now possible.
-
Why should we avoid using closures in Swift structs?
We all love closures, don’t we? Closures make an iOS developer’s life easy. Well, if it makes it easy, then why am I saying to avoid using closures in Swift structs? The reason is, “Memory leaks and unexpected behaviors.” Wait. What? Memory leak in structs? How could that be possible?
-
Swift 5 replaces IntroSort with TimSort in the 'sort()' method
When we hear the term ‘Sorting,’ the algorithms which come to our mind are quicksort, insertion sort, merge sort, bubble sort, heap sort, and other sorting algorithms. We would have used the method
sort()
to sort elements in an array, in our day to day programming tasks. However, have you ever wondered what algorithm does the method uses to sort the items in Swift? Before Swift 5, it was ‘Introsort,’ but after Swift 5, it is ‘Timsort.’ Timsort is a sorting algorithm, used in programming languages like Python, and Java. I am going to cover mostly about ‘Timsort’ in this article. -
Generate URLSession code in Swift using Postman
Almost every iOS developer would have had to make a network call from their app. Swift uses URLSession to make network calls. URLSessionTask includes DataTask, UploadTask, DownloadTask, and WebsocketTask (WebsocketTask is lately introduced in iOS13.0 check this article to know more about it.) I was testing a multipart data request API using the [Postman app.]https://www.getpostman.com/ The API worked, the file got uploaded, and the results came in. However, I needed to write the Swift code to make a multipart request from the iOS app. Writing code for data task can be simple, but the complexity increases when we write code for multipart requests. I was wondering whether Postman can generate the multipart data request code for me, turns out that it could!
-
Introducing URLSessionWebSocketTask - Native WebSocket implementation using Swift 5
We all love WebSockets, don’t we? They have a vast range of applications such as chat applications, push notifications, and much more. I got excited when I stumbled upon “URLSessionWebSocketTask”. That’s right, in addition to data task, download task, and upload task, we have websocketTask! in URLSession. Websockets are now first-class citizens in the foundation framework. Before websocket tasks, we had to use third-party libraries like Star Scream or Socket Rocket, but it is not the case anymore.
-
Swift bit #4 - Swifty ways of typecasting objects
Often we find ourselves in a situation where we need to check whether an object belongs to a particular class or not. For example, consider there is a UIView, and there are many subviews like UITextView, UILabel, and UIStepper. Now you have to find the UILabel from the parent view and change its text value. So how do we do that? Well, there are multiple ways of doing it.
-
Enabling 'Sign in with Apple'in developer account
‘Sign in with Apple’ is an exciting feature announced in WWDC 2019. You must be wondering how to get started. Well, this article is about completed the configuration, Click here to know how to integrate ‘Sign in with Apple’ feature in your iOS apps.
-
Integrating 'Sign in with Apple' in iOS apps
The WWDC 2019 gave us many features to look forward. One of the most exciting features and my favorite is the ‘Sign In with Apple’ feature in iOS 13. The users can sign in securely, and their privacy is guaranteed. Apple is holding up their biggest promise of privacy with this feature. It is available for web and other platforms as well. We will be exploring and learning the integration of ‘Sign In with Apple’ on different platforms in the upcoming articles. Now, let us get started with how we can integrate it into our iOS app.
-
Swift bit #3 — Unwrap optional values using for in loop
One of the most widely used features in Swift are the optionals. Optionals are types that can hold either a value or a nil value i.e nil.
-
Swift bit #2 - Using Booleans the right way, in Swift
Boolean is one of the most frequently used and simplest data type in any programming language.It is common to want to toggle the state of the boolean variable. So, we normally do it like this,
-
Swift bit #1 — Using “where” clause in “for in” loops
We all would have written a piece of code similar to this, The usual way,
-
Humble beginnings
Blogging has always been my favorite exercise. I started creating websites using Wordpress, PHP, and PHPBB nearly ten years back. After a point, I took the path of iOS development. I became an iOS developer. Learning things in iOS was challenging as well as it was fun at the same time. As I discovered new things, I thought, why shouldn’t I share my knowledge with other fellow developers? And this is the reason why I have started the blog. So much has evolved since then. With the introduction of new technologies and frameworks, there are so many ways to set up a website. The challenge is to select the right technology for the intended purpose. After doing in-depth research, I made up my mind to set up a blog using Jekyll. Yes, Jekyll powers ohmyswift.com. Thanks to the developer community, which helped me in choosing the right framework to set up my blog.