久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <tfoot id='R0spm'></tfoot>
      <i id='R0spm'><tr id='R0spm'><dt id='R0spm'><q id='R0spm'><span id='R0spm'><b id='R0spm'><form id='R0spm'><ins id='R0spm'></ins><ul id='R0spm'></ul><sub id='R0spm'></sub></form><legend id='R0spm'></legend><bdo id='R0spm'><pre id='R0spm'><center id='R0spm'></center></pre></bdo></b><th id='R0spm'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='R0spm'><tfoot id='R0spm'></tfoot><dl id='R0spm'><fieldset id='R0spm'></fieldset></dl></div>
    1. <legend id='R0spm'><style id='R0spm'><dir id='R0spm'><q id='R0spm'></q></dir></style></legend>
      • <bdo id='R0spm'></bdo><ul id='R0spm'></ul>
    2. <small id='R0spm'></small><noframes id='R0spm'>

        Swift 的標準庫和名稱沖突

        Swift#39;s standard library and name collision(Swift 的標準庫和名稱沖突)

        <tfoot id='IXziC'></tfoot>

          <small id='IXziC'></small><noframes id='IXziC'>

          <i id='IXziC'><tr id='IXziC'><dt id='IXziC'><q id='IXziC'><span id='IXziC'><b id='IXziC'><form id='IXziC'><ins id='IXziC'></ins><ul id='IXziC'></ul><sub id='IXziC'></sub></form><legend id='IXziC'></legend><bdo id='IXziC'><pre id='IXziC'><center id='IXziC'></center></pre></bdo></b><th id='IXziC'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='IXziC'><tfoot id='IXziC'></tfoot><dl id='IXziC'><fieldset id='IXziC'></fieldset></dl></div>

                  <tbody id='IXziC'></tbody>
                  <bdo id='IXziC'></bdo><ul id='IXziC'></ul>
                • <legend id='IXziC'><style id='IXziC'><dir id='IXziC'><q id='IXziC'></q></dir></style></legend>
                • 本文介紹了Swift 的標準庫和名稱沖突的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我知道 Swift 不使用命名空間,但名稱是在每個模塊中定義的.首先,我不太明白這是如何避免名稱沖突的 - 請隨意詳細說明.

                  I know that Swift doesn't use namespaces, but that names are defined within each module. First of all, I don't understand very well how this avoids name collisions -feel free to elaborate.

                  不過,我的主要問題是:假設我想要一個不使用 NSTreeNode 的樹結構,所以我創建了自己的名為TreeNode"的類.現在假設 Apple 決定在 Swift 的標準庫中包含一個用于構建樹的類,并且正如預期的那樣,他們將其命名為TreeNode".那會發生什么?我的自定義 TreeNode 將與標準庫的 TreeNode 發生沖突...在這種情況下我是否必須更改所有代碼?或者,Apple 會承諾 Swift 的標準庫在未來不會改變?

                  Nevertheless, my main question is: Let's say I want a tree structure without using NSTreeNode, so I make my own class named "TreeNode". Now let's say that Apple decides to include a class to build trees in Swift's standard library, and, as expected, they name it "TreeNode". What happens then? My custom TreeNode will collide with Standard Library's TreeNode... Will I have to change all my code in cases like that? Or maybe Apple will promise that Swift's Standard Library will not change in the future?

                  這里回答了問題(感謝@Martin R 的評論)

                  Question answered here (thanks @Martin R for your comment)

                  推薦答案

                  Swift 中的命名空間是隱式的.所有類和其他符號都屬于定義它們的目標(模塊).因此,如果您定義類 String,則完全限定名稱將是 MyTarget.String.當發生名稱沖突時,您必須在類名前加上定義它的模塊(框架),除非在當前模塊中定義了具有該名稱的類 - 此類優先且不需要前綴.

                  Namespacing in Swift is implicit. All classes and other symbols belong to the target (module) they are defined in. So if you define a class String the fully qualified name would be MyTarget.String. When there is a name collision, you have to prefix the class name with the module (framework) it is defined in, except when there is a class with that name defined in the current module - this class takes precedence and does not need to be prefixed.

                  struct String {
                      var swiftString = ""
                  }
                  
                  var a = String()
                  var b = Swift.String()
                  

                  因此,如果您創建了您的類 TreeNode 并且 Apple 后來也添加了一個 TreeNode,如果您只使用一個模塊并且您不會需要改變任何東西.如果您想使用 Swift 的 TreeNode,則需要將其稱為 Swift.TreeNode.

                  So if you create your class TreeNode and Apple later adds a TreeNode as well, your name would take precedence if you are using only one module and you wouldn't need to change anything. If you would want to use Swift's TreeNode, you would need to refer to it as Swift.TreeNode.

                  這篇關于Swift 的標準庫和名稱沖突的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Swift: Geofencing / geolocations near user location(Swift:用戶位置附近的地理圍欄/地理位置)
                  Are namespace collisions really an issue in Objective-C?(命名空間沖突真的是 Objective-C 中的一個問題嗎?)
                  Swift Extension: same extension function in two Modules(Swift 擴展:兩個模塊中的相同擴展功能)
                  Retrieving Keys From GeoFire within Radius in Swift(在 Swift 中從 Radius 中的 GeoFire 檢索密鑰)
                  MKMapView MKCircle renders a circle with too big radius(MKMapView MKCircle 渲染一個半徑太大的圓)
                  Invalid Float value - swift 3 ios(無效的浮點值 - swift 3 ios)

                      <legend id='Hle9q'><style id='Hle9q'><dir id='Hle9q'><q id='Hle9q'></q></dir></style></legend><tfoot id='Hle9q'></tfoot>

                      <small id='Hle9q'></small><noframes id='Hle9q'>

                      • <bdo id='Hle9q'></bdo><ul id='Hle9q'></ul>

                          • <i id='Hle9q'><tr id='Hle9q'><dt id='Hle9q'><q id='Hle9q'><span id='Hle9q'><b id='Hle9q'><form id='Hle9q'><ins id='Hle9q'></ins><ul id='Hle9q'></ul><sub id='Hle9q'></sub></form><legend id='Hle9q'></legend><bdo id='Hle9q'><pre id='Hle9q'><center id='Hle9q'></center></pre></bdo></b><th id='Hle9q'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Hle9q'><tfoot id='Hle9q'></tfoot><dl id='Hle9q'><fieldset id='Hle9q'></fieldset></dl></div>
                              <tbody id='Hle9q'></tbody>
                          • 主站蜘蛛池模板: 自拍偷拍亚洲一区 | 国产成人高清在线观看 | 9porny九色视频自拍 | 亚洲色图在线观看 | 一级黄色片在线免费观看 | 玩丰满女领导对白露脸hd | 无码一区二区三区视频 | 欧美在线视频一区二区 | 亚洲精品不卡 | 亚洲一区二区中文字幕在线观看 | 一区欧美 | a黄在线观看 | 成人在线精品视频 | 一级黄a视频 | 国产伦精品一区二区三区照片91 | 亚洲欧美激情精品一区二区 | 日本在线播放一区二区 | 日韩在线播放中文字幕 | 亚洲一区二区三区免费视频 | 亚洲欧美视频 | 成人免费观看视频 | 亚洲国产精品精华素 | 免费国产视频 | 亚洲国产一区二区三区 | 国产91亚洲精品 | 91免费看片| 水蜜桃久久夜色精品一区 | 亚洲在线一区 | 亚洲成人动漫在线观看 | 亚洲国产精品区 | 久久精品一 | 午夜丁香视频在线观看 | 成人做爰999| 日韩精品av一区二区三区 | 日韩一区二区三区视频 | 久久久久久黄 | 亚洲精品乱码久久久久久按摩观 | 91大神新作在线观看 | 久久精品国产一区二区三区不卡 | a级毛片免费高清视频 | 亚洲欧美日韩国产综合 |