Get value from selected picker row in WatchKit 2 - swift

I'm using Xcode 7 and I'm trying to pass a value from the picker to another function when a button is pressed. Is it possible to get the value of the row that is currently selected in the picker? Or do I have to use the picker as the button somehow? I tried implementing didSelectRow but when I try setting it up, I get an error: Use of undeclared type 'UIPicker View.' I'm guess I have to retrieve the index of the source array somehow.

UIKit is not available for Apple Watch, and it is specially designed for iOS. Else you must use WatchKit.
In order to use user interface (UI) elements in your WatchKit App (watchOS1 or 2), you must use WatchKit (WK) elements instead, such as WKInterfaceButton.
So in order to have your app running successfully, replace UIPicker (which is an UIKit element) with WKInterfacePicker (which is a WatchKit element).
Note that WKInterfacePicker will only work in watchOS 2 (or later).

You are trying to use a UIKit class.
Use Watchkit classes with watch os 2:
WKInterfacePicker

Related

iOS CallKit: CXProviderConfiguration localizeName is deprecated

Currently, CXProviderConfiguration localizeName is deprecated.
https://developer.apple.com/documentation/callkit/cxproviderconfiguration
let configuration = CXProviderConfiguration(localizedName: "Call")
=> 'init(localizedName:)' was deprecated in iOS 14.0
How can I set its localizeName now?
I want to show the name("Call") in the right-bottom.
If I understood correctly your question, you want to display a custom string below the button with your app icon in the CallKit UI.
Contrary to what I thought and wrote in the comment, the localizedName of CXProviderConfiguration, prior to iOS 14 was used as the label of the button mentioned above.
On iOS 14 and above, instead, is the Product Name that's used for that purpose. You can find it in the build settings of your target, and by default, it's equal to your target name. Keep in mind that it's also the string displayed below your app icon on the home screen.

How to pass data from Swift file to SwiftUI file

I want to pass the variable TeamOne2 (right file) from the file which is created with UIKit to the file which is created with SwiftUI (left file). How can I do that? Struct.Variable does not work.
The reason is that I created my app with Storyboard and UIKit and want to use the Widget which comes with iOS 14. But I cannot rewrite my code to SwiftUI because I just want to use the Widget.
Xcode Screenshot

Drag and Drop using swift 4 on mac OS

I'm using swift 4 and Xcode 9 and I have a problem with implementation of drag and drop. I have a custom 'destination' view for drops and in swift 3 i call
register(forDraggedTypes: Array(NSURLPboardType))
to accept drags that contain those types.
How can I do somethings like this in swift 4?
Now I have this code
registerForDraggedTypes([.pdf])
And no one NSDraggingDestination method calls when I drop a pdf in my view.
(my custom view sits on top)
So my colleague found solution of this problem, in swift 4 you have to use kUTTypes casted as String for drag and drop, like this:
registerForDraggedTypes([NSPasteboard.PasteboardType(rawValue: kUTTypeFileURL as String), NSPasteboard.PasteboardType(rawValue: kUTTypeItem as String)])
With this code all NSDraggingDestination methods works fine, you can drop any file from finder in your view.

Xcode Storyboard not updating custom class Designables

I have had many problems after closing Xcode which one of them is that Xcode Storyboard is not updating Custom Class Designables anymore and do not show the content. For example I use "SkyFloatingLabelTextField" which worked perfeclty before so I can't blame the library. Is there some way so I can force it to update it?
What I mean illustration:
As you can see, in the first picture I have assigned the custom class and there is actually textField inside my viewController which for some reason doesn't show up anymore in Storyboard but works on real device or simulator.
So can I force it somehow?
I tried removing the class and all runtime values, clean, build close Xcode but nothing is working.
Huhh... Enabling "Automatically refresh views" did the trick. For some reason it was turned off in my case. If you do not know what I mean, then it is the setting in Editor -> Automatically refresh views

How do I create a NSToggleButton in Interface Builder?

I want to make an NSToggleButton because it suits my needs perfectly: show one image when toggled on, another when it's toggled off.
From Apple's Developer website:
"After the first click, the button displays its alternate image or title; a second click returns the button to its normal state.
This option is called “Toggle” in Interface Builder’s Button Inspector.
Available in OS X v10.0 and later."
- Source
When looking at the Round Rect Button I created in Interface Builder, however, I can't find a "Toggle" attribute. My google and StackOverflow searches yield only questions around attributes for the control, but I haven't found a tutorial for creating this button in particular.
How do I create a NSToggleButton in Interface Builder? Where is it in the Object library?
The source you provdided is for OSX programming. Not iOS however this can be implemented yourself. A UIButton is just a UIView so add a UIImageView as a subview then when the button is clicked set hidden to either YES or NO
NSToggleButton is an AppKit class -- MacOS X only. You won't find it if you're building an iOS app. Classes from the Foundation framework have an NS prefix and are available in iOS (NSArray, NSDictionary, etc.), but the user interface classes in iOS are in UIKit and have a UI prefix. Take a look at UISwitch for similar functionality.