I have some confusion about strings. Are strings just mapped to their native platform counter part?
Can I not call standard swift string functions? How do I maximize my portability of core swift code?
I have some confusion about strings. Are strings just mapped to their native platform counter part?
Can I not call standard swift string functions? How do I maximize my portability of core swift code?
Currently, yes. with some extension methods defined for them in Swift.dll
. See Differences and Limitations for details.
Thanks for the link. Like with structs, the API difference is very worrisome for me. Is there some way I can add additional methods to String so that it can support the same API?
I tried creating an extension to String to add the lastPathComponent computed property, but I got a compiler error.
Simply adding an extension like you did should work. i’ll test that myself in a second.
Ideally, wed course love contributions such as this to the core Swift Base Library, which we’ll be open sourcing later this week.
—marc
Reproduced. it looks like extension methods work, but properties do not. We’ll fix for the next build.
import System.Collections.Generic
import System.Linq
import System.Text
extension String {
var foo: String { return "foo" }
func bar() -> String { return "bar" }
}
println("The magic happens here.".bar())
println("The magic happens here.".foo) // No member "foo" on type "String!"
``
thanx!
Thanks, logged as bugs://71544: Silver: can’t call extension properties
Looking forward to seeing the core Swift Base Library getting open sourced.
bugs://71544 got closed with status fixed.