Cannot assign value of type 'IndexPath' to type 'Int'

cannot assign value of type '()' to type ' string '
cannot assign value of type t to type t
cannot assign value of type bool to type 'string
cannot assign value of type url to type 'string
cannot assign value of type 'string to type uilabel
cannot assign value of type to type array
cannot assign value of type cgfloat to type 'string
cannot assign value of type string to type binding<string

I wonder how to declare a variable of type IndexPath. It will also be very helpful if someone can show me how to use inline conditional for this.

var indexPath = 0
if  PlaylistController.shared.playlists.count == 1 {
    indexPath = IndexPath(item: sender.tag +1, section: 0)
}
else {
    indexPath = IndexPath(item: sender.tag -1, section: 0)
}

Simply change the line:

var indexPath = 0

to:

let indexPath: IndexPath

Or replace the whole thing with:

let indexPath = IndexPath(item: sender.tag + (PlaylistController.shared.playlists.count == 1 ? 1 : -1), section: 0)

Cannot assign value of type 'String?' to type 'String?', Cannot assign value of type 'String?' to type 'String?' This is my function where it happens in override func setupCell<String>(data: String?) main.swift:2:8: error: cannot assign value of type 'String' to type 'Int' varA = "This is hello" Type Inference. Type inference enables a compiler to deduce the type of a particular expression automatically when it compiles your code, simply by examining the values you provide. Swift 4 uses type inference to work out the appropriate type as


let indexPath : IndexPath = 
    PlaylistController.shared.playlists.count == 1 ?
        IndexPath(item: sender.tag+1, section: 0) :
        IndexPath(item: sender.tag-1, section: 0)

Or, clearer I think:

let item = PlaylistController.shared.playlists.count == 1 ? sender.tag+1 :sender.tag-1
let indexPath = IndexPath(item:item, section:0)

Cannot assign value of type 'Int' …, Cannot assign value of type 'Int' to type 'String?' I am new to programming and swift 3. I got an error message when I was trying to make a simple math game. How to Assign Value of Type Double to Type String? Hey guys, I'm having a problem when attempting to display data from an API JSON feed in a tableview. While some of my functions are strings, others are double or int.


Just specify type of your variable as IndexPath since this is type which you need to store (you don't want to save number)

var indexPath: IndexPath

Cannot assign value of type 'ViewController' to type, Describe the bug Delegate method is not getting called, Insert ' as! UITextFieldDelegate' To Reproduce class ViewController: UIViewController,  Hi all, i am facing below issue when i am working level 3 assignment . “Cannot assign from type ‘UiPath.Core.QueueItem’ to type ‘System.String’ in Assign activity ‘End Process’.” As per document i have changed ‘TransactionItem’ variable type to string in GetTransactionData, Process, and SetTransactionStatus files. i am facing above issue only in GetTransactionData state


Can't compile: Cannot assign value of type '() -> Void' to type , Anyone have an idea how to fix it? ../Pods/SCLAlertView/SCLAlertView/​SCLAlertView.swift:409:22: Cannot assign value of type '() -> Void' to  Two different types with this name exist, but they are unrelated. Type '<T> (x: <G extends boolean> () => Type<G, T>) => void' is not assignable to type 'U'. Types of parameters 'x' and 'x' are incompatible. Type 'Type<G, T>' is not assignable to type 'Type<G, number>'.


Getting error called "Cannot assign value of type 'String' to this , I am getting the error message ""An error occured on Form:11400. Event:​EmptyUDTs.Cannot assign value of type 'String' to this contextual object (requires a  The ‘cannot assign expression of type’ error happens when we try to store a value in a variable that holds a different kind of values. For instance we cannot store a colour value in a true/false variable. And we cannot put a true/false value into a number variable. Here's how we fix the ‘cannot assign expression of type’ error:


Cannot assign generic closure to variable with arguments of wider , a:@escaping (T,PartialKeyPath<T>)->Void) { self.root = r // works self.keypath = kp // works self.action = a // Cannot assign value of type '(T,  The following statement would not compile as you cannot assign a null value to a value type. Int32 i = null; To assign a null value to a value type, you need to take advantage of a nullable type