{"id":506,"date":"2018-02-23T23:38:51","date_gmt":"2018-02-23T15:38:51","guid":{"rendered":"http:\/\/60.205.208.74\/2018\/02\/23\/swift-%e6%95%99%e7%a8%8b\/"},"modified":"2018-02-23T23:38:51","modified_gmt":"2018-02-23T15:38:51","slug":"swift-%e6%95%99%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=506","title":{"rendered":"Swift \u6559\u7a0b"},"content":{"rendered":"<span itemprop=\"description\"><div class=\"article-body\">\n<div class=\"article-intro\" id=\"content\">\n<h1>Swift \u6559\u7a0b<\/h1>\n<div class=\"tutintro\">\n<img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/swift.png\" alt=\"Swift \u6559\u7a0b\"><\/p>\n<p>Swift \u662f\u4e00\u79cd\u652f\u6301\u591a\u7f16\u7a0b\u8303\u5f0f\u548c\u7f16\u8bd1\u5f0f\u7684\u5f00\u6e90\u7f16\u7a0b\u8bed\u8a00,\u82f9\u679c\u4e8e2014\u5e74WWDC\uff08\u82f9\u679c\u5f00\u53d1\u8005\u5927\u4f1a\uff09\u53d1\u5e03\uff0c\u7528\u4e8e\u5f00\u53d1 iOS\uff0cOS X \u548c watchOS \u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>Swift \u7ed3\u5408\u4e86 C \u548c Objective-C \u7684\u4f18\u70b9\u5e76\u4e14\u4e0d\u53d7 C \u517c\u5bb9\u6027\u7684\u9650\u5236\u3002<\/p>\n<p>\nSwift \u5728 Mac OS \u548c iOS \u5e73\u53f0\u53ef\u4ee5\u548c Object-C \u4f7f\u7528\u76f8\u540c\u7684\u8fd0\u884c\u73af\u5883\u3002<\/p>\n<p>2015\u5e746\u67088\u65e5\uff0c\u82f9\u679c\u4e8eWWDC 2015\u4e0a\u5ba3\u5e03\uff0cSwift\u5c06\u5f00\u653e\u6e90\u4ee3\u7801\uff0c\u5305\u62ec\u7f16\u8bd1\u5668\u548c\u6807\u51c6\u5e93\u3002<\/p>\n<\/div>\n<hr>\n<h2>\u8c01\u9002\u5408\u9605\u8bfb\u672c\u6559\u7a0b\uff1f<\/h2>\n<p>\n\u672c\u6559\u7a0b\u9002\u5408\u60f3\u4ece\u4e8b\u79fb\u52a8\u7aef(iphone)\u5f00\u53d1\u6216 OS X \u5e94\u7528\u7684\u7f16\u7a0b\u4eba\u5458\uff0c\u5982\u679c\u4e4b\u524d\u6709\u7f16\u7a0b\u57fa\u7840\u66f4\u597d\u3002<\/p>\n<p>\n\u672c\u6559\u7a0b\u6240\u6709\u5b9e\u4f8b\u57fa\u4e8e Xcode8.2.1\uff08Swift 3.0.2 \u7684\u8bed\u6cd5\u683c\u5f0f\uff09 \u5f00\u53d1\u6d4b\u8bd5\u3002<\/p>\n<hr>\n<h2>\u7b2c\u4e00\u4e2a Swift \u7a0b\u5e8f<\/h2>\n<p>\u7b2c\u4e00\u4e2a Swift \u7a0b\u5e8f\u5f53\u7136\u4ece\u8f93\u51fa &#8220;Hello, World!&#8221; \u5f00\u59cb\uff0c\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<div class=\"example\">\n<h2 class=\"example\">\u5b9e\u4f8b<\/h2>\n<div class=\"example_code\">\n<div class=\"hl-main\"><span class=\"hl-mlcomment\">\/*<\/span><span class=\"hl-mlcomment\"> \u6211\u7684\u7b2c\u4e00\u4e2a Swift \u7a0b\u5e8f <\/span><span class=\"hl-mlcomment\">*\/<\/span><span class=\"hl-code\"><br \/>\n<\/span><span class=\"hl-identifier\">var<\/span><span class=\"hl-code\"> <\/span><span class=\"hl-identifier\">myString<\/span><span class=\"hl-code\"> = <\/span><span class=\"hl-quotes\">&#8220;<\/span><span class=\"hl-string\">Hello, World!<\/span><span class=\"hl-quotes\">&#8220;<\/span><span class=\"hl-code\"><\/p>\n<p><\/span><span class=\"hl-identifier\">print<\/span><span class=\"hl-brackets\">(<\/span><span class=\"hl-identifier\">myString<\/span><span class=\"hl-brackets\">)<\/span><\/div>\n<\/div>\n<p><a target=\"_blank\" href=\"\/try\/runcode.php?filename=HelloWorld&#038;type=swift\" class=\"showbtn\">\u8fd0\u884c\u5b9e\u4f8b \u00bb<\/a>\n<\/div>\n<p><b>\u5b9e\u4f8b\u89e3\u6790<\/b><\/p>\n<ul>\n<li>\n<p><strong>var myString = &#8220;Hello, World!&#8221;<\/strong> : \u4f7f\u7528 var \u5173\u952e\u5b57\u5b9a\u4e49\u4e00\u4e2a\u53d8\u91cf myString\uff0c\u503c\u4e3a Hello, World!<\/p>\n<\/li>\n<li>\n<p><strong>print<\/strong> : \u8f93\u51fa\u53d8\u91cf\u7684\u503c<\/p>\n<\/li>\n<\/ul>\n<hr>\n<h2>\u76f8\u5173\u8d44\u6599<\/h2>\n<ul>\n<li>\n<p><a href=\"https:\/\/developer.apple.com\/library\/content\/documentation\/Swift\/Conceptual\/Swift_Programming_Language\/GuidedTour.html\" target=\"_blank\">Swift \u5b98\u65b9\u624b\u518c (Swift 3.0.1)<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"http:\/\/www.runoob.com\/manual\/gitbook\/swift3\/source\/_book\/chapter2\/01_The_Basics.html\" target=\"_blank\">Swift \u4e2d\u6587\u624b\u518c<\/a><\/p>\n<\/li>\n<\/ul><\/div>\n<\/p><\/div>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">Swift \u6559\u7a0b Swift \u662f\u4e00\u79cd\u652f\u6301\u591a\u7f16\u7a0b\u8303\u5f0f\u548c\u7f16\u8bd1\u5f0f\u7684\u5f00\u6e90\u7f16\u7a0b\u8bed\u8a00,\u82f9\u679c\u4e8e2014\u5e74&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=506\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,28],"tags":[74,119],"class_list":["post-506","post","type-post","status-publish","format-standard","hentry","category-mobile","category-swift","tag-ios","tag-swift","zoom-theme-has-thumb"],"_links":{"self":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/506","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=506"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/506\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=506"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=506"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=506"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}