Author: Sergey Kargopolov

Software developer

Web: www.appsdeveloperblog.com

In this Swift code example, you will learn how to play the music mp3 file from a remote URL in Swift. The code example below will cover: Create AVPlayer and AVPlayerItem, Create UIButton programmatically, Create AVPlayerLayer and add it as a subview, Handle the Play button action to Pause and Play music, Set UIImage on…

Read More AVPlayer. Play Music MP3 File From a Remote URL In Swift.

In this tutorial, you will learn how to remove the DEBUG banner in the Flutter app. If you run Flutter mobile application runs on Android emulator or iOS simulator it will show a DEBUG label in the right side upper corner. Removing the DEBUG Banner The DEBUG label will be automatically removed when you build…

Read More How to Remove the DEBUG Banner in Flutter App

In this Swift code example, you will learn how to add a playback slider to an AVPlayer, so that users can start playing music from any place they wish. The code example below will cover the following: Create AVPlayer and AVPlayerItem, Create UIButton programmatically, Create AVPlayerLayer and add it as a subview, Handle Play Button action…

Read More Add Playback Slider to AVPlayer. Example In Swift.

In this Swift code example, you will learn how to determine user’s current location using CLLocationManager and CLLocationManagerDelegate. The code example below will cover: Request user’s permission for your app to always be able to read user’s location. Optionality you could use requestWhenInUseAuthorization() instead of requestAlwaysAuthorization(), Update projects Info.plist with String values for NSLocationAlwaysUsageDescription and…

Read More Determine User’s Current Location Example in Swift

Error handling is the process of responding to and recovering from error conditions in your mobile app. Some operations aren’t guaranteed to always complete execution or produce a useful output. When an operation fails, it’s often useful to understand what caused the failure, so that your code can respond accordingly. Handle Error with Do, Try…

Read More Error Handling Example in Swift

In this short Swift code example, you will learn how to compare two strings despite their case sensitivity. To do that we will use the caseInsensitiveCompare() function and the ComparisonResult enumeration. Using caseInsensitiveCompare() and ComparisonResult let valueExpected = “SUCCESS” let valueProvided = “success” if valueExpected.caseInsensitiveCompare(valueProvided) == ComparisonResult.orderedSame { print(“Strings are equal”) } In the code example above, the caseInsensitiveCompare…

Read More Case Insensitive Comparison of Strings in Swift

In this short Swift code example, you will learn how to: Initialize an Array with 5 elements in Swift, Remove an element from an array at the specified index. Create an Array Let’s first create a new array with some elements in it. // Initialize Array with 5 elements var myArray = [1,2,3,4,5] // Print…

Read More Remove Element From an Array at Specified Index in Swift

Lets’ create an Array with three elements first. var myArray = [“Swift”, “Objective-C”, “PHP”] Now we can loop through all elements in Array for arrayElement in myArray { print(arrayElement) } Loop through an array of elements and print out element index as well as element value. for (index, element) in myArray.enumerated() { print(“Element index: \(index).…

Read More Loop Through Array Elements in Swift

In this tutorial, you will learn how to create a very simple Spring Cloud API Gateway Global Pre-filter and Post filter classes. Global filters are executed for every route defined in the API Gateway. The main difference between pre-filter and post-filter class is that the pre-filter code is executed before Spring Cloud API Gateway routes the request…

Read More Spring Cloud API Gateway Global Filter Example

Let’s create a Dictionary with two elements first. var myDictionary = [“first_name”: “Sergey”, “last_name”: “Kargopolov”] Now we can remove all elements from a Dictionary. myDictionary.removeAll() print(myDictionary) For more Swift code examples and tutorials, please check the Swift Code Examples page on this website.

Read More Remove All Items From a Dictionary

First, let’s create a Dictionary with two elements. var myDictionary = [“first_name”: “Sergey”, “last_name”: “Kargopolov”] print(myDictionary) Now we can add a new key with a value. myDictionary[“user_id”] = “f5h7ru0tJurY8f7g5s6fd” We should now have 3 key-value pairs printed print(myDictionary) For more Swift code examples and tutorials, please check the Swift Code Examples page on this website.

Read More Add Item to a Dictionary in Swift

In this Swift code example, you will learn how to make the music playback slider smoothly move as the music continues to play so that the user is visually aware of how much of the music file has been already played and how much is left to play. Create AVPlayer and AVPlayerItem Create UIButton programmatically…

Read More AVPlayer. Add Periodic TimeObserver to Update Music Playback Slider