Append String in Swift

前端 未结 12 1291
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 00:43

I am new to iOS. I am currently studying iOS using Objective-C and Swift.

To append a string in Objective-C I am using following code:

 NSString *str         


        
12条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 00:50

    In the accepted answer PREMKUMAR there are a couple of errors in his Complete code in Swift answer. First print should read (appendString) and Second print should read (appendString1). Also, updated println deprecated in Swift 2.0

    His

    let string1 = "This is"
    let string2 = "Swift Language"
    var appendString = "\(string1) \(string2)"
    var appendString1 = string1+string2
    println("APPEND STRING1:\(appendString1)")
    println("APPEND STRING2:\(appendString2)")
    

    Corrected

    let string1 = "This is"
    let string2 = "Swift Language"
    var appendString = "\(string1) \(string2)"
    var appendString1 = string1+string2
    print("APPEND STRING:\(appendString)")
    print("APPEND STRING1:\(appendString1)")
    

提交回复
热议问题