logo
down
shadow

Generic parameter 'Self' could not be inferred swift


Generic parameter 'Self' could not be inferred swift

Content Index :

Generic parameter 'Self' could not be inferred swift
Tag : swift , By : tayles
Date : January 12 2021, 08:33 AM

hope this fix your issue 1) You have a comma that shouldn't be there. Also, you could use some spacing for readability, and you don't need the semicolon (though Swift will let you put it there):
print("ISBN: " + self.currentISBN! + "  ID:" + book_id! + " Title:" + book_title!)
print("ISBN: \(self.currentISBN!)  ID:\(book_id!) Title:\(book_title!)")

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

generic parameter could not be inferred swift


Tag : ios , By : user140973
Date : March 29 2020, 07:55 AM
I hope this helps you . You can get rid of this error by telling the compiler what you expecting:
let a: [String] = words.distinct()
extension Array where Element : Equatable {
    func distinct() -> [Element]{
        var unique = [Element]()
        for i in self{
            if let item = i as? Element {
                if !unique.contains(item){
                    unique.append(item)
                }
            }
        }
        return unique
    }
}

(Swift 3)generic parameter T could not be inferred


Tag : generics , By : user179863
Date : March 29 2020, 07:55 AM
I wish did fix the issue. You are not telling the compiler anything about what type neededArray should be. It is only natural that the compiler complains. Judging from the context, I think you want neededArray to be an array of T. So explicitly say the type:
let neededArray: [T] = getNestedArray(array: object as! [Any])
guard let neededArray: [T] = getNestedArray(array: object as! [Any]) else { return nil }
let result: [Int] = getNestedArray(array: [1, [2, [3, [4]]]])!

Generic parameter 'A' could not be inferred (Swift 4, Bond and ReactiveKit frameworks migrating from Swift 2)


Tag : swift , By : Rob
Date : March 29 2020, 07:55 AM
With these it helps If you ever migrated from old versions of ReactiveKit/Bond implemented syntax, here is how to do it for your UIKit Reactive Extensions:
import UIKit
import Bond
import ReactiveKit

extension ReactiveExtensions where Base: UISearchBar {

    var delegate: ProtocolProxy {
        return base.protocolProxy(for: UISearchBarDelegate.self, setter: NSSelectorFromString("setDelegate:"))
    }

    var text: DynamicSubject<String?> {

        let selector = #selector(UISearchBarDelegate.searchBar(_:textDidChange:))
        let textChanged = delegate.signal(for: selector) { (subj: SafePublishSubject<Void>, _: UISearchBar, _: NSString) in
            subj.next(())
        }

        return dynamicSubject(
            signal: textChanged,
            get: { $0.text },
            set: { $0.text = $1 }
        )
    }
}

extension UISearchBar: BindableProtocol {

    public func bind(signal: SafeSignal<String?>) -> Disposable {
        return reactive.text.bind(signal: signal)
    }
}

Generic parameter 'Self' could not be inferred (swift 4)


Tag : xcode , By : OlioEngr
Date : March 29 2020, 07:55 AM
With these it helps range(of / index(of returns an optional. You have to unwrap the optional in the range expression
extension String
{
    func substringToFirstChar(of char: Character) -> String?
    {
        guard let pos = self.range(of: String(char))?.lowerBound else { return nil }
        // or  guard let pos = self.index(of: char) else { return nil }
        let subString = self[..<pos]
        return String(subString)
    }
}
extension String
{
    func substringToFirstChar(of char: Character) -> String
    {
        guard let pos = self.range(of: String(char))?.lowerBound else { return self }
        // or  guard let pos = self.index(of: char) else { return self }
        let subString = self[..<pos]
        return String(subString)
    }
}

Swift : Generic parameter 'T' could not be inferred


Tag : swift , By : NewGirl
Date : March 29 2020, 07:55 AM
This might help you You're very close. Say you have a struct A that conforms to P. Then you could specify the generic parameter as follows:
var fp: A? = f()
Related Posts Related QUESTIONS :
  • Why return nil tableViewCell for UITableViewDiffableDataSource cellProvider param?
  • Xcode 11 beta and Mac OS Mojave: when I try to create a new project and/or open existing one it closes down with error
  • In Swift, is it a good practice to declare variables with a value assigned?
  • Deriving binding from existing SwiftUI @States
  • Advice for updating old Swift Project
  • Swift AVAssetWriter Record Video with Mic Audio AND Device Audio into a Video with ONE Audio Track AVAssetTrack
  • SwiftUI dismiss modal
  • VStack not filling screen width in ScrollView, does fill in List
  • How to detect a tap gesture location in SwiftUI?
  • Using Xcode/Swift, how can I use an SF Symbol as a tab bar icon in assets? The asset field won't accept the .svg file
  • How to fix Xcode error "Segmentation fault: 11" after adding didSet to @State var
  • Views compressed by other views in SwiftUI VStack and List
  • Why is the modifier .navigationBarTitle not applied to NavigationView?
  • "Cannot Preview in this file - Failed to launch [App Name]"
  • Get the current position of ScrollView in SwiftUI?
  • How to use buildExpression in Swift 5.2 Function Builders?
  • Where do I put a return in a function?
  • SwiftUI - Is there a popViewController equivalent in SwiftUI?
  • How to remove "row" separators from a List in SwiftUI?
  • Understanding @Binding in SwiftUI
  • Convert Realm list of Strings to Array of Strings in Swift
  • Are the #if DEBUG statements really needed for previews in SwiftUI to remove it in a release build?
  • WkWebView in MacOS remains blank on local or remote content
  • Set Toggle color in SwiftUI
  • Reduce a double in swift
  • Trouble Arranging SceneKit Nodes into a Grid
  • Combine in Playgrounds
  • Singleton class can be created without using 'Static'?
  • How do I fix this '<=' is not a prefix unary operator error?
  • What is the property / $property syntax for bindings?
  • Where should I place the process that don't have relation to UI
  • What does the attribute `@EnvironmentObject` mean in the SwiftUI?
  • Is SwiftUI backwards-compatible with iOS 12.x and older?
  • Swift enums with stored fields?
  • Is there a way to pass the object of two different class in one variable in different conditions
  • How to sync input and playback for core audio using swift
  • UserDefaults not working on didload in my project
  • DispatchQueue and [weak self] workItems. Is [weak self] necessary?
  • remove items at multiple indexes in an array
  • How to create a cross dissolve animation when switching between tabs
  • Protocol Extension where Self is ClassA OR ClassB
  • 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
  • swift function returning nil (returning too early)
  • Generic type 'Result' specialized with too many type parameters (got 2, but expected 1)
  • add comma to string integers in swift
  • Swift extend protocol by
  • iOS Swift - Passing data from First ViewController to Third ViewConTroller
  • Is NS_CLOSED_ENUM actually uneditable?
  • Saving and retrieving a struct which is not codable to Userdefaults in Swift
  • How to scroll table view with the whole screen
  • SSD (Single shot detection) or Yolo implementation with Object tracking in swift
  • Why array's append method cannot be used in viewController?
  • How to get touch point outside current app
  • How to search an unknown child
  • How to check if whether a string is all lowercase?
  • How inherit the struct in swift?
  • How to make an empty object in swift
  • Is there a way to include fields such as "BCC" and "CC" using NSSharingService?
  • update Xcode to 10.2.1 run project crash with problem dyld: Library not loaded: @rpath/libswiftCore.dylib
  • Combine a two dimensional array of items
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com