In trying to work with the Calendar function date(bySettingHour:minute:second:of:options:) in a Playground, I get an error
error: date(bySettingHour:minute:second:of:options:) is unavailable:
use
date(bySettingHour:minute:second:of:matchingPolicy:repeatedTimePolicy:direction:)
instead.
Yet the function is still listed in the docs.
Is that function deprecated?
EDIT:
Looking more closely, it looks like that is a function of NSCalendar, but that function is not available in the equivalent Swift object, Calendar.
Is that really true? Calendar and NSCalendar are both available, but their interfaces offer functions with different parameters and behaviors? Ugh.
It appears that if you create a Swift 3 Calendar object, the equivalent function is date(bySettingHour:minute:second:of:matchingPolicy:repeatedTimePolicy:direction:).
Related
This seems to me a weird question, but I have gone through the purescript-datetime and purescript-js-date and I just cannot find a way to get current DateTime. Is there some hidden library function or do I have to go through FFI?
You can use the now or nowDateTime functions from purescript-now.
As I'm not allowed to add an answer to several duplicated questions, I will ask this question and give also one answer ;-)
The undefined symbol was a call to a self written swift function. This function sits in an swift file with only "global" functions (no class in that file). The function is called from several classes and all was good until this morning.
Suddenly I got this link-error message when producing the release product. The funny think was, it was only for ONE function call. All other calls got no errors, and when I commented out this particular function call, all was good. And this function is a very easy one. There is only one function parameter (Int64) and it returns a CLocationCoordinate2D.
I checked all possible solutions found here and at other places in the web. I even copied the function 1:1 as a local function inside the class.. nothing worked.
The final solution was the compiler flag for optimization. For release builds the flag in "Swift Compiler - Code Generation" is set to "Fast, Whole Module Optimization".
After changing that to "Fast, Single Module Optimization", everything worked ...
I think it is simply a bug in the optimization engine.
.. maybe that will help others in similar situations.
In Swift 3.0, the automated changing of function names due to the "Omit Needless Words" rule has caused two functions in an ObjC class to be the same.
- (void)showLoader;
...and...
- (void)show __deprecated_msg("User 'showLoader'");
The problem is that these functions are within a third party Cocoa Pod (otherwise I would just delete the unnecessary 'show' function).
This results in getting the error "Ambiguous use of 'show'" when I try to invoke the function like this:
loader?.show()
Is there a way to reverse the automatic changing of function name in Swift 3.0 or to help the compiler know which function I want to invoke?
Thanks for your help!
See MartinR's answer to my similar question here: Converting to Swift 3 renamed my own Objective-C method
If you owned the code, you could use NS_SWIFT_NAME(showLoader()) after your method declaration to force the ObjC-to-Swift method conversion to be named what you want:
- (void)showLoader NS_SWIFT_NAME(showLoader());
I think it's worth mentioning even though in your case it doesn't exactly solve your problem because you don't own the code.
You can work around this by calling
loader?.perform(Selector("showLoader"))
You will see a warning from the compiler, but it will compile successfully, and things will work correctly at runtime.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla
Additions to the Date object
Date.prototype is an ordinary object (Firefox 41)
Does that mean we can finally use Object.create and call the constructor to get a functional date object, as opposed to using the new keyword? If so, how.
Does that mean we can finally use Object.create and call the constructor to get a functional date object, as opposed to using the new keyword? If so, how.
No, you can't. In fact, it's step in totally other direction - Date.prototype became plain object, and "magic" happens in constructor.
Because we are looking for a way to ban new across the board without exception.
You can use Reflect.construct (but it's just new operator as a function) or use Date factory methods: Date.UTC(year, month[, day[, hour[, minute[, second[, millisecond]]]]]).
Hovewer, using new is recommended way to instantiate ES6 builtins and language standard is clearly moving to more classical approaches to creating instances of classes (you can't use Map or Set without new keyword).
Trying to figure out how to call CGEventCreateScrollWheelEvent from swift.
It looks like it's been removed from the docs:
Old docs: https://developer.apple.com/library/mac/documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html
New docs: https://developer.apple.com/library/prerelease/mac/documentation/Carbon/Reference/QuartzEventServicesRef/index.html
No word on what to replace it with. Anyone know another way to create a scroll wheel event?
According to the Swift devs, C variadic functions are not compatible with Swift variadics, so you won't be able to call it directly. The only workaround at this time is to write a non-variadic wrapper in C or Obj-C, and call that from Swift.