{"id":524,"date":"2018-02-23T23:38:59","date_gmt":"2018-02-23T15:38:59","guid":{"rendered":"http:\/\/60.205.208.74\/2018\/02\/23\/swift-while-%e5%be%aa%e7%8e%af\/"},"modified":"2018-02-23T23:38:59","modified_gmt":"2018-02-23T15:38:59","slug":"swift-while-%e5%be%aa%e7%8e%af","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=524","title":{"rendered":"Swift While \u5faa\u73af"},"content":{"rendered":"<span itemprop=\"description\"><div class=\"article-body\">\n<div class=\"article-intro\" id=\"content\">\n<h1>Swift While \u5faa\u73af<\/h1>\n<p><a href=\"\/swift-loops.html\"><img decoding=\"async\" class=\"navup\" src=\"\/images\/up.gif\" alt=\"Swift \u5faa\u73af\">Swift \u5faa\u73af<\/a><\/p>\n<p>Swift while\u5faa\u73af\u4ece\u8ba1\u7b97\u5355\u4e00\u6761\u4ef6\u5f00\u59cb\u3002\u5982\u679c\u6761\u4ef6\u4e3atrue\uff0c\u4f1a\u91cd\u590d\u8fd0\u884c\u4e00\u7cfb\u5217\u8bed\u53e5\uff0c\u76f4\u5230\u6761\u4ef6\u53d8\u4e3afalse\u3002<\/p>\n<h3>\u8bed\u6cd5<\/h3>\n<p>Swift while \u5faa\u73af\u7684\u8bed\u6cd5\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre>\nwhile condition\n{\n   statement(s)\n}\n<\/pre>\n<p>\u8bed\u6cd5\u4e2d\u7684 <b>statement(s)<\/b> \u53ef\u4ee5\u662f\u4e00\u4e2a\u8bed\u53e5\u6216\u8005\u4e00\u4e2a\u8bed\u53e5\u5757\u3002 <b>condition<\/b> \u53ef\u4ee5\u662f\u4e00\u4e2a\u8868\u8fbe\u5f0f\u3002\u5982\u679c\u6761\u4ef6\u4e3atrue\uff0c\u4f1a\u91cd\u590d\u8fd0\u884c\u4e00\u7cfb\u5217\u8bed\u53e5\uff0c\u76f4\u5230\u6761\u4ef6\u53d8\u4e3afalse\u3002<\/p>\n<p>\u6570\u5b57 0, \u5b57\u7b26\u4e32 &#8216;0&#8217; \u548c &#8220;&#8221;, \u7a7a\u7684 list(), \u53ca\u672a\u5b9a\u4e49\u7684\u53d8\u91cf\u90fd\u4e3a <b>false<\/b> \uff0c\u5176\u4ed6\u7684\u5219\u90fd\u4e3a <b>true<\/b>\u3002true \u53d6\u53cd\u4f7f\u7528 <b>!<\/b> \u53f7\u6216 <b>not<\/b>\uff0c\u53d6\u53cd\u540e\u8fd4\u56de false\u3002<\/p>\n<p><b>\u6d41\u7a0b\u56fe\uff1a<\/b><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/11\/swift_while_loop.jpg\"><\/p>\n<h3>\u5b9e\u4f8b<\/h3>\n<pre>\nimport Cocoa\n \nvar index = 10\n\nwhile index &lt; 20 \n{\n   print( \"index \u7684\u503c\u4e3a \\(index)\")\n   index = index + 1\n}\n<\/pre>\n<p>\u4ee5\u4e0a\u7a0b\u5e8f\u6267\u884c\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<pre>\nindex \u7684\u503c\u4e3a 10\nindex \u7684\u503c\u4e3a 11\nindex \u7684\u503c\u4e3a 12\nindex \u7684\u503c\u4e3a 13\nindex \u7684\u503c\u4e3a 14\nindex \u7684\u503c\u4e3a 15\nindex \u7684\u503c\u4e3a 16\nindex \u7684\u503c\u4e3a 17\nindex \u7684\u503c\u4e3a 18\nindex \u7684\u503c\u4e3a 19\n<\/pre>\n<p><a href=\"\/swift-loops.html\"><img decoding=\"async\" class=\"navup\" src=\"\/images\/up.gif\" alt=\"Swift \u5faa\u73af\">Swift \u5faa\u73af<\/a><\/p>\n<\/p><\/div>\n<\/p><\/div>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">Swift While \u5faa\u73af Swift \u5faa\u73af Swift while\u5faa\u73af\u4ece\u8ba1\u7b97\u5355\u4e00\u6761\u4ef6\u5f00&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=524\">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-524","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\/524","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=524"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/524\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}