{"id":507,"date":"2018-02-23T23:38:52","date_gmt":"2018-02-23T15:38:52","guid":{"rendered":"http:\/\/60.205.208.74\/2018\/02\/23\/swift-%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba\/"},"modified":"2018-02-23T23:38:52","modified_gmt":"2018-02-23T15:38:52","slug":"swift-%e7%8e%af%e5%a2%83%e6%90%ad%e5%bb%ba","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=507","title":{"rendered":"Swift \u73af\u5883\u642d\u5efa"},"content":{"rendered":"<span itemprop=\"description\"><div class=\"article-body\">\n<div class=\"article-intro\" id=\"content\">\n<h1>Swift \u73af\u5883\u642d\u5efa<\/h1>\n<p>\nSwift\u662f\u4e00\u95e8\u5f00\u6e90\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u8be5\u8bed\u8a00\u7528\u4e8e\u5f00\u53d1OS X\u548ciOS\u5e94\u7528\u7a0b\u5e8f\u3002\n<\/p>\n<p>\u5728\u6b63\u5f0f\u5f00\u53d1\u5e94\u7528\u7a0b\u5e8f\u524d\uff0c\u6211\u4eec\u9700\u8981\u642d\u5efaSwift\u5f00\u53d1\u73af\u5883\uff0c\u4ee5\u4fbf\u66f4\u597d\u53cb\u597d\u7684\u4f7f\u7528\u5404\u79cd\u5f00\u53d1\u5de5\u5177\u548c\u8bed\u8a00\u8fdb\u884c\u5feb\u901f\u5e94\u7528\u5f00\u53d1\u3002\u7531\u4e8eSwift\u5f00\u53d1\u73af\u5883\u9700\u8981\u5728OS X\u7cfb\u7edf\u4e2d\u8fd0\u884c\uff0c\u56e0\u6b64\u5176\u73af\u5883\u7684\u642d\u5efa\u5c06\u4e0d\u540c\u4e8eWindows\u73af\u5883\uff0c\u4e0b\u9762\u5c31\u4e00\u8d77\u6765\u5b66\u4e60\u4e00\u4e0bswift\u5f00\u53d1\u73af\u5883\u7684\u642d\u5efa\u65b9\u6cd5\u3002\n<\/p>\n<p>\u6210\u529f\u642d\u5efaswift\u5f00\u53d1\u73af\u5883\u7684\u524d\u9898\uff1a<\/p>\n<ol>\n<li>\n\u5fc5\u987b\u62e5\u6709\u4e00\u53f0\u82f9\u679c\u7535\u8111\u3002\u56e0\u4e3a\u96c6\u6210\u5f00\u53d1\u73af\u5883XCode\u53ea\u80fd\u8fd0\u884c\u5728OS X\u7cfb\u7edf\u4e0a\u3002<\/li>\n<li>\n\u7535\u8111\u7cfb\u7edf\u5fc5\u987b\u5728OS 10.9.3\u53ca\u4ee5\u4e0a\u3002<\/li>\n<li>\n\u7535\u8111\u5fc5\u987b\u5b89\u88c5Xcode\u96c6\u6210\u5f00\u53d1\u73af\u5883\u3002<\/li>\n<\/ol>\n<h3>Swift \u5f00\u53d1\u5de5\u5177Xcode\u4e0b\u8f7d<\/h3>\n<p>\n<strong>Swift \u5f00\u53d1\u5de5\u5177\u5b98\u7f51\u5730\u5740\uff1a<\/strong><a href=\"https:\/\/developer.apple.com\/xcode\/download\/\" target=\"_blank\">https:\/\/developer.apple.com\/xcode\/download\/<\/a>\u3002<\/p>\n<p><strong>Swift \u5f00\u53d1\u5de5\u5177\u767e\u5ea6\u8f6f\u4ef6\u4e2d\u5fc3\u4e0b\u8f7d\uff08\u56fd\u5185\u6bd4\u8f83\u5feb\uff09\uff1a<\/strong><a href=\"http:\/\/rj.baidu.com\/soft\/detail\/40233.html\" target=\"_blank\">http:\/\/rj.baidu.com\/soft\/detail\/40233.html<\/a><\/p>\n<p><strong>Swift \u6e90\u4ee3\u7801\u4e0b\u8f7d\uff1a<\/strong><a href=\"https:\/\/swift.org\/download\/#latest-development-snapshots\" target=\"_blank\">https:\/\/swift.org\/download\/#latest-development-snapshots<\/a><\/p>\n<p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u53cc\u51fb\u4e0b\u8f7d\u7684 dmg \u6587\u4ef6\u5b89\u88c5\uff0c\u5b89\u88c5\u5b8c\u6210\u540e\u6211\u4eec\u5c06 Xcode \u56fe\u6807\u8e22\u79fb\u52a8\u5230\u5e94\u7528\u6587\u4ef6\u5939\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xcode2.jpg\"><\/p>\n<p>\u4f60\u4e5f\u53ef\u4ee5\u5728 App Store \u4e2d\u641c\u7d22 xcode \u5b89\u88c5\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p>\n<im src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xcode-download.jpg\"><\/im><\/p>\n<hr>\n<h2>\u7b2c\u4e00\u4e2a Swift \u7a0b\u5e8f<\/h2>\n<p>\nXcode \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199 Swift \u4ee3\u7801\u4e86\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u6211\u4eec\u5728\u5e94\u7528\u6587\u4ef6\u5939\u6253\u5f00 Xcode\uff0c\u6253\u5f00\u540e\u5728\u5c4f\u5e55\u9876\u90e8\u9009\u62e9 File =&gt; New =&gt; Playground\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xc1.jpg\"><\/p>\n<p>\u63a5\u7740 \u4e3a playground \u8bbe\u7f6e\u4e00\u4e2a\u540d\u5b57\u5e76\u9009\u62e9 iOS \u5e73\u53f0\u3002<\/p>\n<p>\n<img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xc2.jpg\">\n<\/p>\n<p>Swift \u7684 playground \u5c31\u50cf\u662f\u4e00\u4e2a\u53ef\u4ea4\u4e92\u7684\u6587\u6863\uff0c\u5b83\u662f\u7528\u6765\u7ec3\u624b\u5b66swift\u7684\uff0c\u5199\u4e00\u53e5\u4ee3\u7801\u51fa\u4e00\u884c\u7ed3\u679c\uff08\u53f3\u4fa7\uff09\uff0c\u53ef\u4ee5\u5b9e\u65f6\u67e5\u770b\u4ee3\u7801\u7ed3\u679c\uff0c\u662f\u5b66\u4e60swift\u8bed\u8a00\u7684\u5229\u5668\uff01<br \/>\n<img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xc3.jpg\"><\/p>\n<p>\u4ee5\u4e0b\u662f Swift Playground \u7a97\u53e3\u9ed8\u8ba4\u7684\u4ee3\u7801\uff1a<\/p>\n<pre>\nimport UIKit\n\nvar str = \"Hello, playground\"\n<\/pre>\n<p>\u5982\u679c\u4f60\u60f3\u521b\u5efa OS x \u7a0b\u5e8f\uff0c\u9700\u8981\u5bfc\u5165 Cocoa \u5305 <b>import Cocoa <\/b> \u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>\nimport Cocoa\n\nvar str = \"Hello, playground\"\n<\/pre>\n<p>\u4ee5\u4e0a\u7a0b\u5e8f\u8f7d\u5165\u540e\uff0c\u4f1a\u5728Playground \u7a97\u53e3\u53f3\u4fa7\u663e\u793a\u7a0b\u5e8f\u6267\u884c\u7ed3\u679c\uff1a<\/p>\n<pre>\nHello, playground\n<\/pre>\n<p>\u81f3\u6b64\uff0c\u4f60\u5df2\u7ecf\u5b8c\u6210\u4e86\u7b2c\u4e00\u4e2a Swift \u7a0b\u5e8f\u7684\u5b66\u4e60\uff0c\u606d\u559c\u4f60\u5165\u95e8\u4e86\u3002<\/p>\n<hr>\n<h2>\u521b\u5efa\u7b2c\u4e00\u4e2a\u9879\u76ee<\/h2>\n<p>1\u3001\u6253\u5f00 xcode \u5de5\u5177\uff0c\u9009\u62e9 File =&gt; New =&gt; Project<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xc4.jpg\"><\/p>\n<p>2\u3001\u6211\u4eec\u9009\u62e9\u4e00\u4e2a&#8221;Single View Application&#8221;\uff0c\u5e76\u70b9\u51fb&#8221;next&#8221;\uff0c\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u793a\u4f8bapp\u5e94\u7528\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xc5.jpg\"><\/p>\n<p>\n3\u3001\u63a5\u7740\u6211\u4eec\u8f93\u5165\u9879\u76ee\u540d\u79f0\uff08ProductName),\u516c\u53f8\u540d\u79f0\uff08Organization Name),\u516c\u53f8\u6807\u8bc6\u524d\u7f00\u540d\uff08Organization identifier)<br \/>\n\u8fd8\u8981\u9009\u62e9\u5f00\u53d1\u8bed\u8a00(Language),\u9009\u62e9\u8bbe\u5907\uff08Devices)\u3002<\/p>\n<p>\n\u5176\u4e2dLanguage\u6709\u4e24\u4e2a\u9009\u9879\uff1aObjective-c\u548cswift\uff0c\u56e0\u4e3a\u6211\u4eec\u662f\u5b66\u4e60swift\u5f53\u7136\u9009\u62e9swift\u9879\u4e86\u3002<br \/>\n\u70b9\u51fb&#8221;Next&#8221;\u4e0b\u4e00\u6b65\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xc6.jpg\"><\/p>\n<p>4\u3001\u9009\u62e9\u5b58\u653e\u7684\u76ee\u5f55\uff0c\u5982\u679c\u8981\u4f7f\u7528Git\u6e90\u4ee3\u7801\u7ba1\u7406\uff0c\u5c06\u52fe\u4e0aSource Control\u7684create git repository on My Mac.<br \/>\n\u70b9\u51fbcreate\u521b\u5efa\u9879\u76ee\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xc7.jpg\"><\/p>\n<p>5\u3001\u9879\u76ee\u521b\u5efa\u540e\uff0c\u9ed8\u8ba4\u751f\u6210\u4e86\u4e00\u4e2a\u793a\u4f8b\u6587\u4ef6\uff0c\u53ef\u4ee5\u770b\u5230swift\u5c06oc\u4e2d\u7684h\u548cm\u6587\u4ef6\u5408\u5e76\u6210\u4e86\u4e00\u4e2a\u6587\u4ef6\uff08\u5373swift\u540e\u7f00\u540d\u6587\u4ef6).<br \/>\nMain.storyboard\u76f8\u5f53\u4e8exib\u6587\u4ef6\uff0c\u6709\u6bd4xib\u66f4\u591a\u7684\u529f\u80fd\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xc8.jpg\"><\/p>\n<p>6\u3001\u6253\u5f00main.storyboard,\u9ed8\u8ba4\u770b\u5230\u4e00\u4e2a\u7b80\u5355\u7684\u7a7a\u767d\u7684\u5e94\u7528\u754c\u9762\uff0c\u5927\u5c0f\u4e3a\u5e73\u677f\u754c\u9762\u5927\u5c0f\u3002<br \/>\n\u5982\u679c\u5f00\u53d1\u90fd\u53ea\u9700\u8981\u5f00\u53d1\u517c\u5bb9iphone\u624b\u673a\u7684app,\u90a3\u4e48\u53ef\u4ee5\u628aUse Auto Layout\u7684\u52fe\u53bb\u6389\uff08\u9ed8\u8ba4\u4e3a\u52fe\u4e0a\uff09\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xc9.jpg\"><\/p>\n<p>\n7\u3001\u5f39\u51fa\u4e86\u4e00\u4e2a\u5bf9\u8bdd\u6846\uff0c\u8ba9\u6211\u4eec\u9009\u62e9\u754c\u9762\u5c3a\u5bf8\uff0ciPhone\u6216\u90fd iPad\u3002\u6211\u4eec\u9009\u62e9iPhone\u7684\u5c3a\u5bf8\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xc10.jpg\"><\/p>\n<p>\n8\u3001\u53ef\u4ee5\u770b\u5230\uff0c\u754c\u9762\u5927\u5c0f\u53d8\u4e3a\u4e86\u624b\u673aiphone\u7684\u5bbd\u5ea6\u548c\u9ad8\u5ea6\u3002<\/p>\n<p>\n\u5927\u5bb6\u53ef\u4ee5\u8bb0\u4f4f\u754c\u9762\u76f8\u5173\u7684\u5c3a\u5bf8\uff0c\u65b9\u4fbf\u4ee5\u540e\u5e03\u5c40\u8ba1\u7b97\u4f4d\u7f6e\uff1a\n<\/p>\n<p>\n<img decoding=\"async\" src=\"\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/71019926dbc681e6ef3f4d90ba6b327b_thumb.png\"><\/p>\n<p>\n9.\u6211\u4eec\u4e3a\u754c\u9762\u6dfb\u52a0\u70b9\u5185\u5bb9\uff0c\u5728\u53f3\u4e0b\u65b9\u627e\u5230Text\u63a7\u4ef6\uff0c\u5c06\u5b83\u62d6\u5165storyboard\u4e0a\uff0c\u5e76\u53cc\u51fb\u5199\u5165\u6587\u672c&#8221;Hello World!&#8221;\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xc11.jpg\"><\/p>\n<p>\u8fd0\u884c\u4e00\u4e0b\u6a21\u62df\u5668\uff08command+R \u5feb\u6377\u952e\u6216\u5728\u83dc\u5355\u680f\u4e2d\u9009\u62e9 Product =&gt; Run)\u3002<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/10\/xc12.jpg\"><\/p>\n<p>\u81f3\u6b64\uff0c\u6211\u4eec\u7684\u7b2c\u4e00\u4e2aSwift\u9879\u76ee\u5c31\u5b8c\u6210\u4e86\u3002<\/p>\n<\/p><\/div>\n<\/p><\/div>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">Swift \u73af\u5883\u642d\u5efa Swift\u662f\u4e00\u95e8\u5f00\u6e90\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u8be5\u8bed\u8a00\u7528\u4e8e\u5f00\u53d1OS X\u548ciOS\u5e94\u7528\u7a0b&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=507\">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-507","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\/507","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=507"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/507\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}