Category "swift"

Swift dictionary get key for value

I'm using a swift dictionary of type [UIImage:UIImage], and I'm trying to find a specific key for a given value. In Objective-C I could use allKeysForValue, bu

Rich notification play video clip

I'm trying to get rich notification and play video on the notification. I success to show an image and not found swift sample code. What need to be done to add

Render MKMapView offscreen

I'm trying to render an MKMapView into an UIImage, without showing it on the screen. I init the map: let mapView = MKMapView(frame: CGRect(x: 0, y: 0, width: 1

Render MKMapView offscreen

I'm trying to render an MKMapView into an UIImage, without showing it on the screen. I init the map: let mapView = MKMapView(frame: CGRect(x: 0, y: 0, width: 1

Crash when deleting an item from List in SwiftUI with custom RandomAccessCollection

Basic approach I am currently tring to clean up my Core Data/SwiftUI code, and part of that is moving code out of my Views and into my ViewModels. Since it seem

Can't create an Array of types conforming to a Protocol in Swift

I have the following protocol and a class that conforms to it: protocol Foo{ typealias BazType func bar(x:BazType) ->BazType } class Thing: Foo {

Array does not connect with the tableView(numberOfRowsInSection) method

I have an array which I will store all data that I get from http request and display them on tableView but it seems that tableView(numberOfRowsInSection) does n

How to convert NSString to Int so I can add in swift 3.0

I have a value which seems to be an Int but when I do type(of: value) it returns Optional<Any> and after trying many things I figure that data type NSStri

How can I calculate a distance between two AnchorEntities?

There's a position which is SIMD3 and there's AnchorEntity. I want to get distance between two. How I did it: var distance = distance(position, (self.modelentit

ARView counterpart to SCNView's SCNTechnique?

I have made project with ARKit that uses metal shaders to perform a mirroring effect, and this is assigned by using sceneView.technique. I am trying to figure o

Importing Project-Swift.h into a Objective-C class...file not found

I have a project that was started in Objective-C, and I am trying to import some Swift code into the same class files that I have previously written Objective-C

UIButton not respect Aspect Fill contentMode after resizing animation

I am use auto layout. Following is the initial state of the view. In the centre is a button contained in a view. The button has contentMode Aspect Fill, and t

CLLocationDegrees to String variable in Swift

Given that the code var latitude = userLocation.coordinate.latitude returns a CLLocationDegrees Object, how can I store the value in to a variable so that I

Change a rotation of AnchorEntity in RealityKit

I placed 3d object to ARViewController after 3 seconds of placing object, then I want to rotate object by 90 degrees: arView.scene.addAnchor(anchorEntity) Disp

SwiftUI dragging ScrollView flickers as the keyboard is dismissing

When I develop the feature that allows users drag ScrollView to dismiss keyboard in SwiftUI, I find that if you drag ScrollView as the keyboard is dismissing, t

How to move a model and generate its collision shape at the same time?

I have ModelEntity in SwiftUI and it moves. But the problem is: when adding generateCollisionShape method, it doesn't move anymore. I want a collision effect as

How to sum the numbers(Int16) of stored core data - Swift 3

I have stored the letters(String), numbers(Int16) and Date(Date) in the core data. And the filter(NSPredicate) succeeded in organizing only the necessary data.

SwiftUI customized text field in OSX

I am creating a edit view in SwiftUI for Mac OSX. A user can change his profile. At the moment I am using default Text() elements to view his current values/set

How to determine if one array contains all elements of another array in Swift?

I have 2 arrays: var list:Array<Int> = [1,2,3,4,5] var findList:Array<Int> = [1,3,5] I want to determine if list Array contains all findList elem

Swift - Remove " character from string

I have a string which is "Optional("5")". I need to remove the "" surrounding the 5. I have removed the 'Optional' by doing: text2 = text2.stringByReplacingO