Swiftã¯çµå±ã©ããªã¼ãã³ã½ã¼ã¹ã«ãªã£ãã®ãï¼
ãªã¼ãã³ã½ã¼ã¹åã°ããã¼ãï¼ï¼ã¨ãããããã®ã¯å ¨ç¶èå³ãªãã§ããããããªããã
XCode7ã§ä½æ°ãªãimport Foundation
ãªã©ãããã¨ãã¤ãã§ã«ä»¥ä¸ã®ã©ã¤ãã©ãªããªã³ã¯ããããã¼ã§ãã
SwiftCore
ï¼Swiftã®ã³ã¢è¨èªä»æ§ï¼Darwin
ï¼UNIXãã¼ã¹ã®OSX/iOSã®åºç¤é¨åãCoreFoundationãããã«å«ã¾ããï¼Dispatch
ï¼Grand Central Dispatchï¼CoreGraphics
ï¼æç»å¦çã®åºç¤é¨åãä»ã¯OpenGLã ã¨æãã¾ãããã®ãã¡ä¸èº«ãMetalã«ãªãã®ã§ããããï¼ObjectiveC
ï¼Objective-Cã©ã³ã¿ã¤ã é¢æ°ï¼Security
Swiftããªã¼ãã³ã½ã¼ã¹åããããã¨è¨ã£ã¦ãæ¬å½ã«pure Swiftã®ã³ã³ãã¤ã©ã ããæä¾ããã¦ããã¾ãæå³ããªãã®ã§ããã©ãã¾ã§ãã©ããªã¼ãã³ã½ã¼ã¹ã«ãªãã®ãï¼ãã¨ããã®ãèå³ã®ç¦ç¹ã ã£ããã¨æãã¾ãã
ãUIKit
ã®APIãå¼ã³åºãã ãã§ç°¡åã«ã¢ããªã±ã¼ã·ã§ã³ãä½ããiOSéçºã¨ã¯å¥ç©ã«ãªãããã¨ããã®ã¯ã¾ãåæã¨ãã¦ã
Darwin
ã®äºæå®è£ ã¾ã§ãæä¾ãããããã¾ãã¡èª°å¾ãªè¨èªã«ãªããFoundation
ã¾ã§ãæä¾ããããObjectiveC
ã®åªç¸ããéããããªãã
ã®2æããªã¼ã¨æã£ã¦ãã®ã§ããã
ã¨ããæå¤ãªçãã§ããã
Swiftèªèº«ã§Foundation
ãè¨è¿°ãã¦ãããã¨ããã®ã¯èå³æ·±ãï¼æ®éã®Swiftã¯Objective-Cã®Foundation
å®è£
ãå©ç¨ãã¦ããã ããªã®ã§ï¼ãããããªã¼ãã³ã½ã¼ã¹çã¨ã®ä¸çªã®éãã«ãªãã¨æãã¾ãã
Foundationã®è¡æ¹
ãè¦ã¦ã¿ãã¨ãã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã®åºç¤ã¨ãã¦ä»å¾ãFoundation
ãçããããã¨ãããããªãã¨ãæ¸ãã¦ããã¾ãããã ãæ²ãããã¦ããã´ã¼ã«ã¯ã¡ãã³ã£ã¨å¤ãã£ã¦ãã¾ãã
- Make software development easier by introducing consistent conventions for things such as deallocation.
- Support Unicode strings, object persistence, and object distribution.
ãã
- Make software development easier by introducing consistent conventions.
- Support internationalization and localization, to make software accessible to users around the world.
ã«ããããå¤ãã£ã¦ãã¾ãã
åè ã¯ã¡ã¢ãªç®¡çãARCã«ãªã£ããã¨ã§ãä¾ãã°ã¡ã¢ãªè§£æ¾ã®ãããªãã¨ããå©ãã®æå³ããªããªã£ãããã§ãããããARCã§ãã¡ã¢ãªç®¡çãæèããªãã¨ç°¡åã«ãªã¼ã¯ããã®ã¯å¤ãããªãã®ã§ãå¥ã«ããå¤ããªãã¦ããããªãï¼ã¨æãã®ã§ããã
å¾è
ã¯NSString
ã¯UTF16ã®ã©ããã¼å®è£
ã§ããããä»ã®Unicodeã³ã¼ããã¤ã³ãã¯çµµæåã®ä¾µé£ã§21bitã«ãªã£ã¦ããããªãã¸ã§ã¯ããã·ãªã¢ã©ã¤ãºãã¦æ°¸ç¶åããã¨ããçºæ³ãã®ãã®ãæ代ã«åããªããªã£ã¦ããã®ã§è¡¨ç¾ãå¤ããæãã§ããããã
NSUnimplemented()
ã§æ¤ç´¢æ¤ç´¢ã£ã
ãªããç¾å¨ã®ãªã¼ãã³ã½ã¼ã¹Swiftã®Foundation
ã¯æªå®è£
ãªé¨åãå¤ãã£ãããObjective-Cã©ã³ã¿ã¤ã ã«ã¯åå¨ããã¯ã©ã¹ããªãã£ãããã¾ãã
以ä¸ã®ãããªæ³¨ææ¸ããããã¾ãã
Important: This project is in the early stages of development. It is not yet ready for production use, but it is ready for contributions. It is scheduled to be part of the Swift 3 release.
<ç§è¨³>
éè¦: ãã®ããã¸ã§ã¯ãã¯éçºã®åæ段éã«ããã¾ããããã¯ã¾ã 製åã§ã®ä½¿ç¨ã¯ã§ãã¾ããããã³ã³ããªãã¥ã¼ã·ã§ã³ã®æºåã¯æ´ã£ã¦ãã¾ããSwift 3ã®ãªãªã¼ã¹ã®ä¸é¨ã¨ãã¦äºå®ããã¦ãã¾ãã
åçåä»ããçãããã¯ã©ã¹ã¯ã©ã¹ã¿ã®ä»çµã¿ãªããã¯æ¹æ¶ããããã§ããããããSwiftã«ã¯KVCããªãã®ã§ããããåå°ã«ãã¦ããKVOãããã¾ãããããã«KVOã®ä¸ã«ä¹ã£ãã£ã¦ãCocoa Bindingsã¯æ代ãå åãããããæãã§ããã
ä¸æ¹ã§ãNSZone
ã®ãããªä»ãç¡æå³ãªã¯ã©ã¹ãçãæ®ã£ã¦ãã¾ãããããã¯ãæåã®1å¹´ã¯Foundation
ã®å¯æ¬æ§ãå®ç¾ãããã¨ã«æ³¨åãããã®ç®æ¨ã¨ç¸åããAPIã®ããã°ãã³ãåé¿ãããã¨ãããããªæå³åããããã¿ããã§ããã
Foundation without Objective-C runtime
This project provides an implementation of the Foundation API for platforms where there is no Objective-C runtime. On OS X, iOS, and other Apple platforms, apps should use the Foundation that comes with the operating system. Our goal is to abstract away the exact underlying platform as much as possible.
<ç§è¨³>
ãã®ããã¸ã§ã¯ãã¯ãObjective-Cã©ã³ã¿ã¤ã ã®ãªããã©ãããã©ã¼ã ã®ããã®Foundation APIã®å®è£ ãæä¾ãã¾ããOSXãiOSããã®ä»Appleã®ãã©ãããã©ã¼ã ã«ããã¦ã¯ãã¢ããªã±ã¼ã·ã§ã³ã¯ãªãã¬ã¼ãã£ã³ã°ã·ã¹ãã ã«ä»å±ãã¦ããFoundationãå©ç¨ããã¹ãã§ããæã ã®ã´ã¼ã«ã¯ãå¯è½ãªéãç²¾å¯ãªåºç¤ã¨ãªããã©ãããã©ã¼ã ãæ½è±¡åãããã¨ã§ãã
ç¾ç¶ã§ã¯ãOSXã§Foundationãä¸å®å ¨ãªãªã¼ãã³ã½ã¼ã¹Swiftã使ãæå³ã¯ãªãã®ã§ãXCodeã§ä½¿ãã°ããã£ã¦ãã¨ã§ããã
ãããç¾ç¶ã ããæãã®ããObjective-Cã©ã³ã¿ã¤ã ãå¿ è¦ã¨ããªãFoundationããªã¼ãã³ã½ã¼ã¹ã§éçºãããããOSXãiOSããã¡ãã«ç§»è¡ããã®ã§ããããâ¦ï¼
ãããªãNSãã¬ãã£ã¯ã¹
ã¨ããã§ããã®ãªãã¸ããªã®æç« ã¯å ¨é¨é¢ç½ãã®ã§èªãã ã»ããããã§ãããã§ã«ãã¤ããªã®ããã³ã¼ãããã«ãããããæçãªæ å ±ãå¾ããã¾ããããã¤ãé¢ç½ãã£ãã¨ãããåãä¸ãã¾ãã
API Naming and Foundation
One of the goals of the Swift 3 project is a new set of naming guidelines. The Foundation project will soon update all of its names to match the new guidelines. We will also drop the 'NS' prefix from all classes.
<ç§è¨³>
APIå½åè¦åã¨Foundation
Swift 3 ããã¸ã§ã¯ãã®ã´ã¼ã«ã®ã²ã¨ã¤ã¨ãã¦ãå½åè¦åã®ä¸æ°ãããã¾ããFoundationããã¸ã§ã¯ãã¯ãããæ°ããå½åè¦åã¨ä¸è´ããããã«ãå ¨ã¦ã®å½åãæ´æ°ãããã§ããããå ãã¦ãå ¨ã¦ã®ã¯ã©ã¹ãã'NS'ãã¬ãã£ã¯ã¹ãåãé¤ãã¾ãã
Foundation
ãSwiftã§åå®è£
ãã¦ããã®ä¸ã«è¼ã£ã¦ãããã¬ã¼ã ã¯ã¼ã¯ãå
¨é¨ä½ãç´ãã®ã§ãããããããå¤åã®Swift Arrayã¨åç
§åã®NSArray
ã¯ã©ãããåºå¥ã«ãªããã§ãï¼
How do we decide if something belongs in the standard library or Foundation?
In general, the dividing line should be drawn in overlapping area of what people consider the language and what people consider to be a library feature.
For example, Optional is a type provided by the standard library. However, the compiler understands the concept to provide support for things like optional-chaining syntax. The compiler also has syntax for creating Arrays and Dictionaries.
On the other hand, the compiler has no built-in support for types like NSURL. NSURL also has ties into more complex functionality like basic networking support. Therefore this type is more appropriate for Foundation.
<ç§è¨³>
ã©ã®ããã«ãã¦æ¨æºã©ã¤ãã©ãªã¾ãã¯ãFoundationã®ãããã«å±ãããã®ã ã¨å¤æããã°ããã§ããï¼
ä¸è¬ã«ãè¨èªã®æ©è½ã®ä¸é¨ã ã¨èãã人ã ã¨ãã©ã¤ãã©ãªã®æ©è½ã§ããã¹ãã ã¨èãã人ã ãéãåãããå¢çã§åå²ãããã¹ãã§ãã
ä¾ãã°ãOptionalã¯æ¨æºã©ã¤ãã©ãªã§åã¨ãã¦æä¾ããã¦ãã¾ããããããã³ã³ãã¤ã©ã¯optional-chainingæ§æãªã©ããµãã¼ãããããã®ã³ã³ã»ãããç解ãã¦ãã¾ããã³ã³ãã¤ã©ã¯ã¾ããé åãè¾æ¸ãçæããããã®æ§æãæã£ã¦ãã¾ãã
ä¸æ¹ã§ãã³ã³ãã¤ã©ã¯NSURLã®ãããªåã¯çµã¿è¾¼ã¿ã§ãµãã¼ããã¦ãã¾ãããNSURLã¯åºæ¬çãªãããã¯ã¼ã¯ã®ãµãã¼ããªã©ãããè¤éãªæ©è½ã¨ã®é¢é£æ§ã帯ã³ã¾ãããã£ã¦ããã®åã¯Foundationã®æ¹ãããç¸å¿ããã§ãã
Swiftã«ãããæ¨æºã©ã¤ãã©ãªã¯ç¾ç¶ã«è¿ããããã«ãªæ§æã®ã¾ã¾ãFoundation
ã«æ©è½ãæããã¦ããã¿ããã§ãããSwift 2ã§NSURL
ã«é¢é£ä»ããNSString
ã®ã¡ã½ãããString
ã®æ¡å¼µã«å«ããã®ãããã¾ããããNSURL
ã¯Foundation
ã®ãã®ã ããæ¨æºã©ã¤ãã©ãªããã¯éé¢ããããã¨ãããããªæå³ã ã£ãã®ã§ãããããï¼åç
§åã§ãããã¨ãåæã«ãã¦ããNSPathStore2
ãå¤åã®String
ã«ãã£ã¹ããããã¨ã§èµ·ããããã©ã¼ãã³ã¹å£ååé¿ãç®çã ã¨æã£ã¦ããã®ã§ããï¼
Why not make the existing Objective-C implementation of Foundation open source?
Foundation on Darwin is written primarily in Objective-C, and the Objective-C runtime is not part of the Swift open source project. CoreFoundation, however, is a portable C library and does not require the Objective-C runtime. It contains much of the behavior that is exposed via the Foundation API. Therefore, it is used on all platforms including Linux.
<ç§è¨³>
ãªãæ¢åã®Objective-Cã«ããFoundationå®è£ ããªã¼ãã³ã½ã¼ã¹ã«ããªãã®ã§ããï¼
Objective-Cããã³ãã®ã©ã³ã¿ã¤ã ã§æ¸ãããDarwinã®Foundationã¯ãSwiftã®ãªã¼ãã³ã½ã¼ã¹ããã¸ã§ã¯ãã«ã¯å±ãã¾ãããããããªãããCoreFoundationã¯å¯æ¬æ§ã®ããCã®ã©ã¤ãã©ãªã§ãããObjective-Cã©ã³ã¿ã¤ã ãå¿ è¦ã¨ãã¾ãããããã«ã¯Foundation APIãéãã¦å ¬éããã¦ããæ¯ãèãã®å¤ããå«ã¾ãã¦ãã¾ãããã®ãããLinuxãå«ãå ¨ã¦ã®ãã©ãããã©ã¼ã ã§ä½¿ããã¦ãã¾ãã
ãObjective-Cã®Foundationå®è£
ãå
¬éããã°ãããããï¼ãã£ã¦ããçåã¯ããããã¯Swiftã®ããã¸ã§ã¯ãã¨ã¯é¢ä¿ãªããããã¨ããæ£è«ã§ä¸è¹´ãã¦ãã¾ãããFoundation
ãå¥ã®ãªã¼ãã³ã½ã¼ã¹ããã¸ã§ã¯ãã«ããã°ããã£ãã ããªæ°ãããã®ã§ãããã
Swiftã®ãªã¼ãã³ã½ã¼ã¹åã¯ããããè¨èªã³ãã¥ããã£ãæ´»çºåãã¦Swift 3ã¸é²åãããã¨ã§çµå®ããã£ã¦æããªã®ã§ãããã¼ã
ãã®ã¨ãSwift 2.Xã®è³ç£ã¯å ¨ã¦ã´ãã«ãªãã¨æããã¾ããâ¦ã