swift

Random selection of the file to read

I am trying to pass a random value( file name from enum) to a parameter for the file read method. But it throws an OptinalVal ... (name: TaskName.LvlTwo.allCases.randomElement()!, type: "txt") let conentFile = content lebel.text = contentFile! }

How do I animate an image in SwiftUI?

Hello everyone, help me figure out how to make a picture fall from top to bottom when you click on the button, it was of diff ... enderingMode(.original) .resizable() .frame(width: 128, height: 128) } } } }

Index out of range error. How to fix it?

import Foundation func inputAndCheckValue() -> Int { var tempInput: Int = 0 var resultParse: Bool = false let ... > 99) { print("Заданное время больше максимально возможного") checkMass = false } } }

IOS swift change language

Such a task is required to make the language selection function inside the application. How can I programmatically change the localization in swift?

How to convert centimeters to meters in SWIFT

I ran into a problem with SWIFT. You need to create variables with certain types of data and take the values in the variables ... to enter the height in meters, and this will be 1.76, but the type I have is Int. Help me figure it out. I'm terribly stupid.

Show Splash screen before loading WKWebView

I have a simple app that loads the site: import UIKit import WebKit class ViewController: UIViewController, WKNavigationDeleg ... (myRequest) } } I want to show the LaunchScreen to the user before the site doesn't load. But I can't find how to do it.

Transmitting data in controllers using TabBar

There are two controllers 1 and 2, I need to pass a variable from 1 to 2, I can not do this as a delegate or segue, since the ... { var user2: User? override func viewDidLoad() { super.viewDidLoad() user1 = user2 } }

How do I enable automatic word wrap by syllable?

I have html and css files to show my book in my app. And this code: let headerString = "<meta name=\"viewport\" content=\" ... ide Developers Con- ference, Apple announced ver- sion 4 of Xcode during the Devel- oper Tools State of the Union ad- dress.

swift, ios. How do I convert a negative number to binary?

Hello everyone, please tell me how to translate a negative number into binary, octal or hexadecimal notation? I found a coupl ... oBinaryString(-1) //11111111111111111111111111111111 - правильно Is there a similar function in swift? Thank you in advance

Why can't I add a UInt8 value to an Int?

The maximum number of UInt8 is 255, so we will never assign a value larger than the Int can hold. Therefore, why do we need t ... alue_UInt8: UInt8 = 5 var value_Int: Int = 5 value_Int += value_UInt8 // Error Replace 'value_UInt8' with 'Int(value_UInt8)'

Change object properties without IBOutlet. Swift

I have several labels in the storyboard on the ViewController that have no connection with the class of this storyboard. Outl ... Button) //-> Error //Cannot convert value of type 'UILabel.Type' to expected argument type 'UILabel' } }

Why does collectionView not work?

I have a collectionView with buttons that will display the time (Clickable). Here is my code: import UIKit class CreateWindo ... enshot of my layers (Collection is not filled in) Declaring a class in Cell CollectionView dependencies Cell dependencies

Play the sound in the background. Walking app

Creating an app for walking. I can't solve one problem. First, I will explain the essence of the application. There is a tra ... To me the most important thing play the speech after the timer expires. I will be glad of any help, sorry for the confusion.

TabBar disappears when switching to another ViewController

The controller checks whether the shopping cart contains products. If it has, then the controller opens with a collectionView ... as! NotEmptyCartViewController self.view.insertSubview(vc.view, belowSubview: tabBarController!.tabBar) } }

How do I find out the serial number of a phone or tablet in swift?

How do I find out the serial number of the device (phone or tablet) in swift? What function would return my phone or tablet serial number?

Deleting a cell by swipe doesn't work

The essence is this, I pass the training material and the application grows. And the problem is the following, after adding t ... ws(at: [indexPath], with: .automatic) } return UISwipeActionsConfiguration(actions: [deliteAction]) }

How to limit the range of possible values of the int variable in swift

Suppose there is some variable a of type Int. Is it possible to somehow limit the range of its values, for example 10...20? I ... e less than 10 to it, then write 10. If more than 20, then 20. How to correctly implement this, for example, via get and set?

How to use try, do, catch correctly in swift?

Help please. I want to make a calculator for parsing expressions using Reverse Polish notation. I need to make it so that if ... return items.removeLast() } How do I just output "Error" to the console if the code crashes ? Thank you in advance !!!

How to open a link in your app instead of a browser

The project is built on Ruby on Rails, there are mobile applications for iOS/android. Task: redirect the opening of the link ... on the site, I click the profile link from my phone, and it opens in the mobile app. What will it take to implement this?

Replace the Russian letters with the corresponding English ones in the Swift string

There are var filename: String! filename = "Это новое название строки" How do I convert the value of filename to newFilena ... onding English ones, and replace the space with a dash var newFilename: String! newFilename = "eto-novoe-nazvanie-stroki"