Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 704 Vote(s) - 3.47 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shimming in Swift

#1
According to Apple engineer Elizabeth Reid "shimming" is when you use conditional compilation to reuse code between iOS and OS X. For example:

#if TARGET_OS_IPHONE
@import UIKit;
#define BaseView UIView
#else
@import AppKit;
#define BaseView NSView
#endif

@interface MyView : BaseView

@end


In the WWDC 2014 session [Sharing code between iOS and OS X][1] she also states:

> If you literally translate how you would shim with Objective-C, this
> will not compile in Swift.
>
> There are ways to shim your code in Swift.
>
> But it gets more complicated than your basic conditional compilation
> that we can use in Objective-C.

So, which are the ways to "shim your code" in Swift?


[1]:

[To see links please register here]

Reply

#2
that would look like this in _Swift_:

#if os(iOS)
import UIKit
typealias BaseClass = UIView
#else
import AppKit
typealias BaseClass = NSView
#endif

//

class MyClass : BaseClass {

// ...

}
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through