Google Maps SDK - custom dimensions for info window

Trying to figure out how to customize the dimensions of the info window that comes up after tapping on a marker on the map.As a default, it's not large enough to display the pertinent information in a convenient way. What I am hoping to achieve is a fullscreen view of the title and snippet.will venmo $5 to anyone who can solve this You can create your custom UIView and design using the storyboard which you would like to appear as your info window.Implement the delegate method markerInfoWindow to return the custom view by loading your desired view from the storyboard. It'...

Swift cast self in class func

i have an issue in swift where i want to check for protocol conformance in a class func and then use some static property when the check succeeds. Here's the playground code:import UIKit@objc protocol SearchableObject { static var sortDescriptors: [NSSortDescriptor] { get }}class Test: NSObject {}extension Test { class func loadData() { if self is SearchableObject { println(valueForKey("sortDescriptors")) } else { println("not searchable") } }}class SearchableTest: Test, SearchableObject { class var sortDescript...

How to access variable from other classes to perform calculation in a class?

I am working with 2 classes to create a Banking system to add and deduct amount from my account. I have two classes one class which I will use to enter my transaction amount and types and another class which I will use to work with the math, like adding and deducting the amount from my account once a transaction is done.class TransactionManager { var bal: Int init(bal: Int = 0) { bal = bal } func addCredit(entry: Transaction) -> (res: Bool, bal: Int) { return (true, balance) } func deductCredit(entry: Transaction) -> (res: Bool, balance...

Swift protocol forcing the Equatable protocol

I have define 2 protocols.I need the first one (NameProtocol) to enforce the Equatable protocol.While the other class (BuilderProtocol) have a method that return the first one (NameProtocol).public protocol NameProtocol : Equatable { var name: String { get }}public protocol BuilderProtocol { func build() -> NameProtocol? // Compiler error init()}The compiler error : "Protocol 'NameProtocol' can only be used as a generic constraint because it has Self or associated type requirements"I need the object return by build() to return an object conforming to the NamePro...

Swift recursive closure stack overflow bug

Update: It should be noted that the question below is of academic nature and the use of core location, or the polling of location data is not relevant to the question - the proper way to do this is always through the core location delegate method. My original question eventually boiled down to: "Is infinite recursion ever possible in swift? (or tail recursion)". The answer to this is no. This is what caused my error due to stack space exhaustion.Original question:I'm having an issue with a recursive function that passes values through a closure. I'm a longtime Objective-C d...

Adding and transitioning animations in SceneKit

I looked at Banana game from WWDC which is written in Objective - C was trying to convert the code to swift for importing animation and transitioning between them but I am having problems running the animations in swift from DAE files.I have exporter DAE files in both AutoDesk format from 3DSMAx and in openCollada format. The autodeskformat the animtation is for each bone so I am unable to call an animation by name so I just import the scene and do the following for the animation to start as soon as the file loads. scene = SCNScene(named: "monster.scnassets/monsterScene.DA...

Real time NSTask output to NSTextView with Swift

I'm using an NSTask to run rsync, and I'd like the status to show up in the text view of a scroll view inside a window. Right now I have this:let pipe = NSPipe()task2.standardOutput = pipetask2.launch()let data = pipe.fileHandleForReading.readDataToEndOfFile()let output: String = NSString(data: data, encoding: NSASCIIStringEncoding)! as StringtextView.string = outputAnd that get's me the some of the statistics about the transfer, but I'd like to get the output in real time, like what get's printed out when I run the app in Xcode, and put it into the text view. Is there a wa...

Firestore - GetDocument() crashes app if document does not exist

When i try to fetch a non-existent Firestore document my app crashes The Firestore documentation says that I should just get a null document, not a terminal error https://firebase.google.com/docs/firestore/query-data/get-data Note: If there is no document at the location referenced by docRef, the resulting document will be null.my code to replicate the error is as follows. For this run, just using the two of the simple buttons. The first button (doReadDeepDocument) reads the document to make sure it does exist. The second button (doDeleteDeepDocument) deletes the document...

Swift UIButton : Selected Emoji disappear

I am using 5 UIButton and I'm getting emoji string in this buttons. But the problem is, when I click the button, emoji disappear on the screen. I guess this is highlighted or selected color problem, but I didn't figure out. What should I do for this?My code :func buttonSelectedNot(){ button1.selected = false button2.selected = false button3.selected = false button4.selected = false button5.selected = false}@IBAction func favoriteButtonAction(sender: UIButton) { // Save Data buttonSelectedNot() sender.selected = !sender.selected; if (sender.select...

How to get a user attribute from an AWS Cognito user pool in Swift?

I'm using AWS Cognito user pools with Amazon's Swift sample app. I'm able to create users with a given_name attribute, but it's not obvious how to later retrieve the given_name. The Amazon sample retrieves attributes as a AWSCognitoIdentityUserGetDetailsResponse and then dumps them to the screen. However, I can't find documentation for AWSCognitoIdentityUserGetDetailsResponse. It appears to be something of an array, but it's not obvious to me how to just pull out a given_name from the returned attributes. One would think that returning attributes as a dictionary would b...

Constructors in Swift

I need some help in constructors in swift. I am sorry, if this question is incorrect or repeated, but I didn't found an answer to my question in another links. So, I have a class class myClass { override init(){ print("Hello World") }}And I have an another classclass anotherClass { let variable = myClass() }Could somebody correct this code? Because it gives me error. I don't know how to explain my question in Swift, because I am newbie. But I will try to explain it, I want to say that when I create an object of the class "myClass", firstly constructor should work and p...

Swift - How to add a layer on a UIImageView inside of a UICollectionViewCell and keep the parallax effect

I'm working on a tvOS project. This project contains a UICollectionView with a UIImageView inside of each UICollectionViewCell. First of all I'm using adjustsImageWhenAncestorFocused on the image, because it looks good when the cell is in focus and I want to have the 'parallax' effect.When a cell is in focus there should pop up an label over the image(for the title of a product) which is not a problem to make. But I want the title to be good readable so thats why I want to put on a gradient layer on top of the image.The problem:When I add the gradient layer to the UIImageVi...

How to call a extension file for a border of pitcure in swift

My code below is supposed to feature a customizable border for a photo taken. I originally had a border but it was not customizable. I saw this code online about a customizable border in a extension file (CALAYER). Its obviously to me I have to call the CALYAER function in my class file (x1ViewController) for the border to appear I just don't know how to do it. import UIKitextension CALayer {func addBorder(edge: UIRectEdge, color: UIColor, thickness: CGFloat) { let border = CALayer(); switch edge { case UIRectEdge.top: border.frame = CGRect(x: 0, y: 0, width...

Not getting full response in swift HTTP request?

I'm using google directions API. When i send the request i'm getting half of the response.This is my code:func getDirections(_ origin: String!, destination: String!, completionHandler: @escaping ((_ status: String, _ success: Bool) -> Void)) { if let originLocation = origin { if let destinationLocation = destination { //var directionsURLString = baseURLDirections + "origin=" + "\(6.935299),\(79.880783)" + "&destination=" + "\(6.909411),\(79.894254)" + "&mode=driving" var directionsURLString = "https://maps.googleapi...

Screen sharing status of the Mac

I am currently facing a problem in detecting the screen sharing status of the Mac via my app. Is there any way to get the status of screen sharing of the Mac? Check here: https://developer.apple.com/documentation/appkit/nsscreenThere is a class for this called NSScreen [XXX]

How to patch/mock a method in Swift?

I'm not experienced in Swift yet.if I have a piece of code that does this:if UserDefaults.standard.bool(forKey: Constants.isTermsAccepted) == false { openDisclaimer()}In Python I could patch the openDisclaimer() method to replace it with a MagicMock. Once I run the test and the assert would reveal if that MagicMock was called or not. I don't care what is happening inside that method, only that it was called or not. Is something like that possible in Swift?UPDATE:Adding the method's implementationfunc openDisclaimer() { let popupVC = UIStoryboard(name: "Main", bund...

Page 1 of 91  |  Show More Pages:  Top Prev Next Last