Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

swift NSURLをstringで手軽に作る

More than 5 years have passed since last update.

swiftでNSURLのurlで手軽にstringでつくる際の、
手抜き作成用メモ。

// アプリバージョンをStringで
let version: String! = NSBundle.mainBundle().objectForInfoDictionaryKey("CFBundleShortVersionString") as? String

// 指定URLと文字連結
var myUrlStr:String = "http://hooogeee.com?v=" + version

// NSURL型に変換するなら
var myUrl:NSURL = NSURL(string:myUrlStr)!

swift1.2で確認しました。

matsuyoro
げーむくりえいたー。 顔は濃いが存在の薄さに悩んでいる。 無敵のエンジニアに出会いたい。 書籍「仕事はたのしいかね」の、大きな事でも試してみればの精神に感銘を受けている。 好きな言葉:好きこそものの上手なれ / 楽は苦の種、苦は楽の種
https://matsudapress.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away