logo
down
shadow

SWIFT QUESTIONS

Cannot subscript a value of type 'String' with an index of type 'String.Index'
Cannot subscript a value of type 'String' with an index of type 'String.Index'
around this issue String is a Collection but not a MutableCollection, which means that the subscript is read-only. Also subscripting can not be used to remove a collection element.To remove the character at the found position, use
TAG : swift
Date : November 13 2020, 07:01 PM , By : Bear
Swift enum cases with same name
Swift enum cases with same name
will help you Let's say I have the following enum: , You could create another enum that represent the volume:
TAG : swift
Date : November 11 2020, 07:00 PM , By : mosbif
How to fix 'Cannot call value of non-function type 'UIColor''
How to fix 'Cannot call value of non-function type 'UIColor''
it fixes the issue As I just start learning programming, it shows the following errors that my code have. , Looks like you are using old code so replace:
TAG : swift
Date : November 11 2020, 07:00 PM , By : shakhawat
How to add more cases for enum in swift
How to add more cases for enum in swift
I wish this helpful for you This is not possible. Adding a case to an enum in an extension is comparable to add (not computed) property for a class or struct. (This is also not possible)See also the documentation:
TAG : swift
Date : November 11 2020, 07:00 PM , By : Pantelis Sventzouris
Does somebody know, why this even compile?
Does somebody know, why this even compile?
I wish did fix the issue. There is a lot of different Double initializers, but any should except String as a parameter. , From the documentation of Double's failable init:
TAG : swift
Date : November 03 2020, 07:01 PM , By : HelioSeven
Is there a Swift built-in for a default dict, similar to Array(repeating: 0, count: x)?
Is there a Swift built-in for a default dict, similar to Array(repeating: 0, count: x)?
I wish this helpful for you Is there a way to create a default dictionary for counting Characters/Strings/whatever? Python has the convenient Counter() class, but I can't find anything for Swift that can just instantiate full of whatever, similar to
TAG : swift
Date : October 24 2020, 06:10 PM , By : Venkata Swamy
Why is my collection view cell returning the error "The dequeued cell is not an instance of TileCollectionViewCell&
Why is my collection view cell returning the error "The dequeued cell is not an instance of TileCollectionViewCell&
Hope that helps Call register(_:forCellWithReuseIdentifier:) method when setup the collection view
TAG : swift
Date : October 24 2020, 06:10 PM , By : Andrew_David
ARKit – How to display the feed from a virtual SCNCamera placed on SCNPlane?
ARKit – How to display the feed from a virtual SCNCamera placed on SCNPlane?
wish help you to fix your issue After some research and sleep, I came to the following, working solution (including some inexplainable obstacles):Currently, the additional SCNCamera feed is not linked to a SCNMaterial on a SCNPlane, as it was the ini
TAG : swift
Date : October 24 2020, 06:10 AM , By : Matas Alejandro Cast
"Result of '&&' unused" warning in a do/try/catch block
"Result of '&&' unused" warning in a do/try/catch block
seems to work fine There is nothing wrong with doing it that way. The "right" way, when something like isTooShort belongs to you and you want to call it without capturing the result, is to mark it with @discardableResult. If you did that, then you co
TAG : swift
Date : October 24 2020, 06:10 AM , By : Steve
How to load a model and textures from a remote server using ARKit?
How to load a model and textures from a remote server using ARKit?
seems to work fine So, since I want to load everything from a remote server, nothing locally here is what I came up with thanks to some help from @ATV.Solution: Loop though child nodes and set texture to the same name as the node.name. You can set th
TAG : swift
Date : October 24 2020, 06:10 AM , By : Yao Lai
Finding words within an Array
Finding words within an Array
wish helps you Here is a less naive solution that will work for strings that contain punctuation.This first splits the string into words using localized rules. It then finds the intersection of the two arrays of words.
TAG : swift
Date : October 22 2020, 06:10 AM , By : George Foreman
UILabel's not updating while in a loop?
UILabel's not updating while in a loop?
wish helps you Don't use infinite while loops (or while running) loops on iOS. That blocks the thread on which you run the loop. Your attempt to update the UI with a call to DispatchQueue.main.async() won't work until the loop returns, which it doesn
TAG : swift
Date : October 22 2020, 06:10 AM , By : Patrick
Resetting zone allocator with allocations still alive
Resetting zone allocator with allocations still alive
hope this fix your issue Calling mapView.removeAnnotations(mapView.annotations) in the deinit fixed it for me. It was occurring only if there were clustered annotations and the map was being zoomed or panned right before deallocation.
TAG : swift
Date : October 22 2020, 06:10 AM , By : Bryan McGuire
How to write swift properties calculated in later stage of Object's lifecycle
How to write swift properties calculated in later stage of Object's lifecycle
This might help you "Constant once fetched" is not constant. There is some period of time when it's not set, and some point later when it is. The fact that it's fetched from the network means that it may fail, so your code has to deal with that (i.e.
TAG : swift
Date : October 22 2020, 06:10 AM , By : Adolfo Gonzalez
Comparing arabic characters with and without diacritic marks
Comparing arabic characters with and without diacritic marks
I wish this helpful for you Trying to compare two arabic strings, one with diacritic marks and one without. , You can compare() the strings with the .diacriticInsensitive option:
TAG : swift
Date : October 20 2020, 06:10 AM , By : tomb69
Combine a two dimensional array of items
Combine a two dimensional array of items
wish help you to fix your issue Create an empty array result with type [[Int]]. If intersection of current Set with any element of result is not empty, update the Set with its union. Else append the Set in result array.
TAG : swift
Date : October 14 2020, 06:10 PM , By : Makanaki
update Xcode to 10.2.1 run project crash with problem dyld: Library not loaded: @rpath/libswiftCore.dylib
update Xcode to 10.2.1 run project crash with problem dyld: Library not loaded: @rpath/libswiftCore.dylib
this will help Actually, the problem is the Framework152x.framework is developed in Swift with Xcode version below 10.2. If your project is built with Xcode 10 with Framework152x.framework means Framework152x.framework runtime is swift 4.2. But if yo
TAG : swift
Date : October 14 2020, 02:00 PM , By : Jinneth Castillo Mut
How to make an empty object in swift
How to make an empty object in swift
Does that help How do I initialize an empty object in swift? This is what I have but it wants the parameters too , Create the class/struct with optional properties like this
TAG : swift
Date : October 14 2020, 03:00 AM , By : Martín Gotelli Feren
Is there a way to include fields such as "BCC" and "CC" using NSSharingService?
Is there a way to include fields such as "BCC" and "CC" using NSSharingService?
Hope that helps Im wondering if there is a way to compose an email in Swift and have it populate fields such as CC and BCC. , This works in Swift5 (Xcode 10.2.1, macOS 10.14.5)
TAG : swift
Date : October 14 2020, 03:00 AM , By : Leah Clark
How inherit the struct in swift?
How inherit the struct in swift?
fixed the issue. Will look into that further structs can only inherit (if that is the right word) from protocols. The cannot inherit from a base struct so you cannot do
TAG : swift
Date : October 14 2020, 02:00 AM , By : Stephen Black
How to check if whether a string is all lowercase?
How to check if whether a string is all lowercase?
With these it helps I've got the code below. I want the string to be capitalized if the user input is all lowercased. Does swift offer this feature? I know in Python is ".islower()". I tried googling, I tried typing .is and seeing what comes up, but
TAG : swift
Date : October 14 2020, 12:00 AM , By : Akshay Ananthapadman
How to search an unknown child
How to search an unknown child
it should still fix some issue The simplist solution is to change the structure to match the type of query you want, and/or add an additional structure(s). This is a very common technique in NoSQL databases.
TAG : swift
Date : October 13 2020, 10:00 PM , By : Mark Vigs
How to get touch point outside current app
How to get touch point outside current app
like below fixes the issue I want to develop one iOS app. Is there any way to get the ui touch point when app in background. Like i want tap randomly in iOS device screen and my app will get correspond touch point accordingly. , Fortunately, this is
TAG : swift
Date : October 13 2020, 08:00 PM , By : albert davenport
Why array's append method cannot be used in viewController?
Why array's append method cannot be used in viewController?
I think the issue was by ths following , You should call the append inside a function after the vc is fully initated
TAG : swift
Date : October 13 2020, 07:00 PM , By : Ilyasse El Mahjoub
SSD (Single shot detection) or Yolo implementation with Object tracking in swift
SSD (Single shot detection) or Yolo implementation with Object tracking in swift
wish help you to fix your issue Object tracking isn't a feature of SSD or YOLO. They treat each new frame as completely different. Just because you detected an object in frame N and the "same" object again in frame N+1, doesn't mean SSD/YOLO understa
TAG : swift
Date : October 13 2020, 06:00 PM , By : tapaj
How to scroll table view with the whole screen
How to scroll table view with the whole screen
it fixes the issue Instead of adding collectionView separately inside the controller's view, you can add the collectionView in tableView's headerView.1. Create a custom UIView - HeaderView, that will contain a UICollectionView
TAG : swift
Date : October 13 2020, 05:00 PM , By : nitin badhe
Saving and retrieving a struct which is not codable to Userdefaults in Swift
Saving and retrieving a struct which is not codable to Userdefaults in Swift
hope this fix your issue If you can't change your struct, then create an extension for it and conform it to Codable.Once conformed to Codable, you can use JSONEncoder and JSONDecoder to convert to and from data and then save/retrieve from UserDefault
TAG : swift
Date : October 13 2020, 02:00 PM , By : simurg56
Is NS_CLOSED_ENUM actually uneditable?
Is NS_CLOSED_ENUM actually uneditable?
like below fixes the issue When you use NS_CLOSED_ENUM, you are making a promise to consumers of your API that the enum will never change, either now in the future. Of course, there is nothing stopping you from making that change, but if you do, you'
TAG : swift
Date : October 13 2020, 11:00 AM , By : Jignesh Shah
iOS Swift - Passing data from First ViewController to Third ViewConTroller
iOS Swift - Passing data from First ViewController to Third ViewConTroller
Hope that helps You could create a segue between A and C.Then in A view controller, check the destination view controller:
TAG : swift
Date : October 13 2020, 09:00 AM , By : evasanthruban
Swift extend protocol by
Swift extend protocol by
it should still fix some issue You can achieve what you're looking for using a protocol and a protocol extension.1. Create a protocol name FreeManager with 2 methods,
TAG : swift
Date : October 13 2020, 07:00 AM , By : Dady Supyandi
add comma to string integers in swift
add comma to string integers in swift
should help you out You can try to convert the prices to integers first and then divide by 100 – so you have a decimal/float values. Then convert back to string using NSNumberFormatterUpdate
TAG : swift
Date : October 13 2020, 06:00 AM , By : Gaoming
Generic type 'Result' specialized with too many type parameters (got 2, but expected 1)
Generic type 'Result' specialized with too many type parameters (got 2, but expected 1)
Hope this helps It's Swift.Result, not Swift.Result. If you want to pass two values, use a tuple, i.e. Swift.Result (the tuple can be auto-expanded in a switch/case handling of the result)Also, Alamofire defines it's own Result type. You should prefi
TAG : swift
Date : October 13 2020, 04:00 AM , By : Alexander Meeus
Protocol Extension where Self is ClassA OR ClassB
Protocol Extension where Self is ClassA OR ClassB
With these it helps No, you cannot use || (or something equivalent) in the where clause of a protocol extension.If the extension method needs certain functionality which is present in both ClassA and ClassB then you can define that in a protocol (to
TAG : swift
Date : October 13 2020, 03:00 AM , By : Sunny
Typecasting a Double value to Int64 in Swift, number of digits is 13, but the system that its running on is a 32 bit sys
Typecasting a Double value to Int64 in Swift, number of digits is 13, but the system that its running on is a 32 bit sys
will be helpful for those in need It makes no difference: A Double is a 64-bit floating point number, and an Int64 is a 64-bit signed integer – no matter if the code is compiled for a 32-bit or a 64-bit platform.Platform-dependent types are for examp
TAG : swift
Date : October 13 2020, 03:00 AM , By : Raw One
swift function returning nil (returning too early)
swift function returning nil (returning too early)
will help you You need a completion as the method itemProvider.loadItem(forTypeIdentifier is asynchronous
TAG : swift
Date : October 13 2020, 03:00 AM , By : User12121
How to create a cross dissolve animation when switching between tabs
How to create a cross dissolve animation when switching between tabs
This might help you How can a simple cross dissolve animation be written in the tab controller class that performs when switching between tabs. , Make use of the UITabBarControllerDelegate method:
TAG : swift
Date : October 12 2020, 11:00 PM , By : Nabaa Riyad
DispatchQueue and [weak self] workItems. Is [weak self] necessary?
DispatchQueue and [weak self] workItems. Is [weak self] necessary?
I wish did fix the issue. but does the instance of MyCustomClass keep a reference to the enclosed workItem block that's passed to async()?
TAG : swift
Date : October 12 2020, 09:00 PM , By : Christopher Vejsada
remove items at multiple indexes in an array
remove items at multiple indexes in an array
will help you code below removes only the first item in the array with color property set to "black" , You can try
TAG : swift
Date : October 12 2020, 09:00 PM , By : hej
UserDefaults not working on didload in my project
UserDefaults not working on didload in my project
will be helpful for those in need Using a class with a static variable for a UserDefaults value is bad practice. Apart from that setting the static variable doesn't update the value in UserDefaults.In the button action set the value in UserDefaults a
TAG : swift
Date : October 12 2020, 08:00 PM , By : overst8
How to sync input and playback for core audio using swift
How to sync input and playback for core audio using swift
it helps some times There may be at least 4 things contributing to the round trip latency. 512 samples, or 11 mS, is the time required to gather enough samples before remoteIO can call your callback.
TAG : swift
Date : October 12 2020, 07:00 PM , By : Geoff Craz
Is there a way to pass the object of two different class in one variable in different conditions
Is there a way to pass the object of two different class in one variable in different conditions
I wish did fix the issue. This is an expected behavior since your language is an actual class, instead of something a bit more flexible.Possible solutions:
TAG : swift
Date : October 12 2020, 05:00 PM , By : saikiran gone
Swift enums with stored fields?
Swift enums with stored fields?
wish of those help You can conform to RawRepresentable and use (Int, Int) as Self.RawValue:
TAG : swift
Date : October 12 2020, 01:00 PM , By : GUOHUI QIAN
Is SwiftUI backwards-compatible with iOS 12.x and older?
Is SwiftUI backwards-compatible with iOS 12.x and older?
wish help you to fix your issue I just checked it out in Xcode 11 and can confirm it won't be backwards-compatible, as can be seen in SwiftUI's View implementation:
TAG : swift
Date : October 12 2020, 11:00 AM , By : Deep Kandpal
What does the attribute `@EnvironmentObject` mean in the SwiftUI?
What does the attribute `@EnvironmentObject` mean in the SwiftUI?
hop of those help? That's for example for Network purposes. You have a class conforming to BindableObject (Beta 5: ObservableObject) and send through the PassthroughSubject (Beta 5: @Published) your data.For example this case:
TAG : swift
Date : October 12 2020, 10:00 AM , By : Travopoly
Where should I place the process that don't have relation to UI
Where should I place the process that don't have relation to UI
I wish this helpful for you SwiftUI gives us same to UIKit’s viewDidAppear() and viewDidDisappear() methods but their name is little bit different which are onAppear() and onDisappear().
TAG : swift
Date : October 12 2020, 09:00 AM , By : Rakia Musah
How do I fix this '<=' is not a prefix unary operator error?
How do I fix this '<=' is not a prefix unary operator error?
To fix this issue The "=" right next to the "40" is confusing Swift (and I think you used "Fix" which added the commas). Here's a functioning version of your code:
TAG : swift
Date : October 12 2020, 08:00 AM , By : Linh Dang
What is the property / $property syntax for bindings?
What is the property / $property syntax for bindings?
it helps some times @State is designed to be used as a binding for SwiftUI properties. Any access to it outside the body accessor of your View will crash with:
TAG : swift
Date : October 12 2020, 08:00 AM , By : Ismail Mellali
Trouble Arranging SceneKit Nodes into a Grid
Trouble Arranging SceneKit Nodes into a Grid
I wish this help you for printed values.When you create your SCNNode, the geometry is centered around pivot point. So if you have a geometry cube with dimension : 200 x 200 x 200 units, the boundingbox goes from (-100, -100, -100) to (100, 100, 100).
TAG : swift
Date : October 12 2020, 06:00 AM , By : Vishal Shakya
Combine in Playgrounds
Combine in Playgrounds
Hope this helps If you created an iOS playground, then Combine should work even if you’re running Xcode 11 or later on macOS 10.14. If you created a macOS playground, Combine will only work if you are running Xcode 11 or later on macOS 10.15 (Catalin
TAG : swift
Date : October 12 2020, 06:00 AM , By : HockyH
Singleton class can be created without using 'Static'?
Singleton class can be created without using 'Static'?
wish help you to fix your issue There are a lot of issues here, so let's clear those up first: This is invalid Swift code. Class and Static both have to be lower cased. Type names in Swift should be UpperCamelCase. The formatting is all wonky.
TAG : swift
Date : October 12 2020, 06:00 AM , By : Serj Ch
Reduce a double in swift
Reduce a double in swift
may help you . A double doesn't have characters. A string rendering of it does. Rather than using the standard String() initializer (which is really only for development use, it's terrible for end-users), use NumberFormatter.
TAG : swift
Date : October 12 2020, 05:00 AM , By : Milin Patel
Set Toggle color in SwiftUI
Set Toggle color in SwiftUI
To fix the issue you can do SwiftUI 1.0 Using ToggleStyle I created a new ToggleStyle to change the three colors of the Toggle (on color, off color, and the thumb).
TAG : swift
Date : October 12 2020, 03:00 AM , By : ShturmanHC
Understanding @Binding in SwiftUI
Understanding @Binding in SwiftUI
around this issue According to this WWDC Talk (Data Flow through Swift UI): https://developer.apple.com/wwdc19/226
TAG : swift
Date : October 12 2020, 02:00 AM , By : Irena Markovic
Convert Realm list of Strings to Array of Strings in Swift
Convert Realm list of Strings to Array of Strings in Swift
around this issue However, how do I convert these Realm Lists back to [String] again
TAG : swift
Date : October 12 2020, 02:00 AM , By : Rafael Justiniano
Are the #if DEBUG statements really needed for previews in SwiftUI to remove it in a release build?
Are the #if DEBUG statements really needed for previews in SwiftUI to remove it in a release build?
fixed the issue. Will look into that further It seems to be removed from the 11 GM Seed. The GM seed release notes say (under Resolved Issues):"The if/endif compiler conditionals surrounding PreviewProvider types have been removed from SwiftUI templa
TAG : swift
Date : October 12 2020, 02:00 AM , By : LightTrepidation
WkWebView in MacOS remains blank on local or remote content
WkWebView in MacOS remains blank on local or remote content
Hope this helps Aaaah, I discovered the problem: apparently even if you don't turn the sandbox on, WKWebView totally fails without it. Not only that, but it fails silently. When I turned the sandbox on, and then enabled outgoing connections, everythi
TAG : swift
Date : October 12 2020, 02:00 AM , By : c.selinn
SwiftUI - Is there a popViewController equivalent in SwiftUI?
SwiftUI - Is there a popViewController equivalent in SwiftUI?
Hope this helps Modify your BView struct as follows. The button will perform just as popViewController did in UIKit.
TAG : swift
Date : October 12 2020, 01:00 AM , By : Shahid Ahmed
How to remove "row" separators from a List in SwiftUI?
How to remove "row" separators from a List in SwiftUI?
With these it helps You may use ForEach within a ScrollView instead of List for dynamic views without any styling
TAG : swift
Date : October 12 2020, 01:00 AM , By : Stanislava Yaneva
Where do I put a return in a function?
Where do I put a return in a function?
To fix this issue I bet you'll want to define counter within the scope of your function (passing it as a parameter might not make sense) and then define sum outside the scope of the if statement like this:
TAG : swift
Date : October 12 2020, 12:00 AM , By : Johan F
Why is the modifier .navigationBarTitle not applied to NavigationView?
Why is the modifier .navigationBarTitle not applied to NavigationView?
will be helpful for those in need Like Martin linked to, navigationBarTitle only works when contained in NavigationView. This is discussed briefly in the SwiftUI Essentials talk at ~52:30. The title ends up flowing up to the NavigationView, so that v
TAG : swift
Date : October 11 2020, 11:00 PM , By : Simone

shadow
Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk