I wanted to share a class with iPhone and Watch Extension.
But some methods and properties are not supported by both targets.
I simply used preprocessor macros:
Done!😄
As well, we can use #if os(watchOS) too since Xcode 7.2!
[Xcode Version 7.3 (7D175)]
[Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)]
[WatchOS version 2.2]
Showing posts with label Swift. Show all posts
Showing posts with label Swift. Show all posts
4/22/2016
4/20/2016
Logging in Swift
We have new keywords such as #file, #function, #line and #column in Swift 2.2, so I modified my logging function.
I can use the function in following way:
And get this output!😄
[Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)]
I can use the function in following way:
And get this output!😄
[Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)]
4/18/2016
NSLocalizedString in Swift
NSLocalizedString in Swift is defined like this:
So, we can use it simply in this way:
For some reason, comment is required...😟
What if I wanna replace some words?:
OK, it works!
But is there any more simple solution?
Inspired by this post on Stack Overflow, I added a small extension to String:
Now I can write this way:
Done! 😄
[Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)]
So, we can use it simply in this way:
For some reason, comment is required...😟
What if I wanna replace some words?:
OK, it works!
But is there any more simple solution?
Inspired by this post on Stack Overflow, I added a small extension to String:
Now I can write this way:
Done! 😄
[Swift version 2.2 (swiftlang-703.0.18.1 clang-703.0.29)]
Subscribe to:
Posts (Atom)