Is it possible to write iOS app using Pure Swift v4.2 without going through Objective-C?


#21

Blockquote
Please give an example. I think there’s some confusion over what you mean by “runtime”, as nothing mentioned so far really has anything to do with the actual Obj-C runtime.

Sorry! I am using Obj-C runtime as umbrella term for : When we pass objects between Swift and Cocoa API through bridge/overlay etc. mechanism, hidden magic and annoyance with NS classes behavior, The memory management of these bridged objects without appropriate hints via the annotations that can be understood by Obj-C ( via compile time optimizations etc.), AnyObject generalizations etc.

Please see the post by @gwendal.roue in the above in this thread for some examples. #selector mechanism and the resulting delegation, KVC and am finding more and more as I am going through this exercise.
The post by @rljames above seems to say some of what I have discovered too.


(Jon Shier) #22

Again, nothing mentioned so far requires any special knowledge of Obj-C, just the markup needed by Swift to operate properly. The closest you get is #selector, and even then you don't need to know where it comes from, so understanding Obj-C gives you nothing. And I'm not sure what you're talking about for memory management: Swift and Obj-C's memory management is the same, as they both use ARC. Generally it's rare to hit the sharp edges of interop, and certainly not something you'd encounter on a regular basis unless your use is solely in those areas.


#23

If I were trying to sum up:

  • One can write full and advanced apps in Swift, without writing any Objective-C code. Really.
  • Swift has features that are Swift features, and happen to be features based on the Objective-C runtime. But these are still genuine Swift features.
  • Those features are basically only one: late binding and message passing. Those are concepts which are not so difficult to grasp (even if they have far-reaching consequences and usages).
  • Those features are documented for the Swift language, not only for ObjC.
  • One can get experience about those features right from Swift.
  • Platform, SDKs, and Frameworks are the same in Swift and Objc. They have to be learned regardless of the language: there's no escape.
  • It may happen sometimes that help comes from an Objective-C veteran. Why not? That's how you'll become a Swift veteran :wink:

(Alik Vovk) #24

Speaking about NS prefixes. You are talking about iOS and most probably about Cocoa Touch. The NS prefix you can see comes from Foundation library. Which is shipped with Swift as a good foundation to write comprehensive software, it includes formatting, date, and other kinds of tools which makes Swift standard library smaller. Most of the NS prefixes were dropped already but there are tools which provide reference mechanic to the Collections, such as NSSet, NSArray, NSDictionary. (As I remember they are also heterogeneous). Which keep the prefix to distinguish from their counterparts.


#25

Well said. I understand that a lot of the interaction between the two are better understood, or easier to grasp, if one knows the origin (Objective-C), but that does not mean there is a necessity to understand it.

e.g. one can learn what @dynamic will do without knowing why Swift has it.


(Joanna Carter) #26

As others have said, you need to give specific examples because, otherwise, I believe what you are talking about is not what you think you are talking about