Newest swift Questions

Q&A for professional and enthusiast programmers

Swift 3: Sharing a calendar I've already made with others within my app?

Through the Calendar app in iPhone you can click on the "i" and share the calendar with someone through their email and I was wondering if there is a way I can do that inside my app. Currently, my ...

UITextField leftView not triggering delegate

I'm using a subclass of UITextField in my TableViewCell. The delegate is set and whenever I tap the textfield, the delegate is called accordingly. However, I've set the textfield's leftViewMode to ....

Read data through Audio Jack iphone

I am looking for a way to read raw data that is being sent from the Arduino through iPhone's audio jack. I searched a lot and found this which detects whether a jack plug is connected or not but ...

Why can I not pass my delegate?

How can I pass the value of didTap to ReminderViewController using delegates ? Here is my code from CustomCell which has didTap protocol BEMCheckBoxDelegate { func checkBox(cell: CustomCell) } ...

NSString to array

I have a Json string like below, which is returned from a .net web service, how can i get this in swift 3? [{"itemno":"AO406705959SE3"},{"itemno":"AO406708959SE3"}] i have try with this coding ...

Detect running on virtual machine

Is it possible to detect if my MacOS app is running on a virtual machine? (I don't mean the simulator, just some VM like VirtualBox or anything else..)

Detect Touch on Edge of the UIVIEW

How to detect the touch on the edge or border of the view in iOS Swift. I want to increase UIView width and height when the user drags the border of the UIView.

Show MasterView first instead of Details

I have a splitview with Master (showing table view) and Details (Showing detail data). When I launch my app it shows detailview first with no data but I need to show masterview first. I know that ...

Calculating word count from a url in swift

I'm creating a reading list app, and I'd like to pass the read time of a user added link to a table cell in their reading list - and the only way to get that number is from that page's word count. I'...

Generic Observer Pattern in Swift using Protocols gives Segmentation Fault

import Foundation class IProtocol { func meth1(arg: Int){} } class IObserver: IProtocol { private var className: String init(name: String) { className = name } override ...

strtod using classic format?

Now functions strtod and strtol support parsing hex number format, infinity, NaN and other non-standard formats. But how to convert string to number using only classic format: 123, 1.23, 0.123, -123,...

Unable to replicate constrains programmatically

I want to add these constrains programmatically in my code: So far I got this: self.view.bringSubview(toFront: sceneView) sceneView.bottomAnchor.constraint(equalTo: canvasUnderReference....

swift why is characters.split used for? and why is map(String.init) used for

import Foundation for i in 1 ... n { let entry = readLine()!.characters.split(" ").map(String.init) let name = entry[0] let phone = Int(entry[1])! phoneBook[name] = phone`` } //...

Unable to add target and run function on UIBarButtonItem click in iOS Swift 3

I'm unable to detect on-click events on UIBarButtonItems in Swift 3. Can anyone help? I need to perform a segue to another storyboard and view controller on clicking the UIBarButtonItem.

Self unresolved identifier

Extreme newbie here. I have copied this code but in the function I receive error: use of unresolved identifier self class ImageProcessor { let image: RGBAImage var avgRed = 0; var ...

Swift 3: Putting data in a file instead of a long array?

sorry, I didn't know how to name the question. My problem is, that I've got an app that is giving the user a random information from an array, and if he clicks on it, it shows a longer information ...

Playground execution aborted: error: Execution was interrupted, reason: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

var str = "Hello, playground" let newTypeString = NSString(string: str) // here is the error // NSString(string: String)

How to instantiate any view first inside a container page view controller?

So I have a container view which holds 3 view controllers. When I launch the app I believe all 3 views instantiates. The issue I am having is this app is deep linking to a 4th view which plays a video ...

Native Component doesn't appear in javascript side

I try to create RCTMap example with swift. I can access to my custom component from javascript, but the map does not appear and I get blank white view. MyMapManager.swift: import Foundation @objc(...

How can I track a user's continuous location in iOS (Swift) whenever they enter or exit certain places?

I'm building an application which has the following requirements: There are X number of locations that the user can check-in or check-out from. Whenever the user enters any of the X locations, I need ...

In Swift how do I access data in my second ViewController from my third ViewController?

I an trying to run the code below so that my ThirdViewController can mirror its "myOrder" variable based off of the one in SecondViewController. But I am getting a runtime error "Swift dynamic cast ...

swift - run app in background continuously

I have been reading apple developer sources on how location updates work and reading tons stack overflow questions on it as well. Im trying to get my users location on my app all the time when the ...

How do I restart when it is out of words/completed? Array! Swift 3

I want to restart the game / words when it is completed. How do I? I'm trying to fix this problem but it is very complicated for me, I am beginner!! var array = [ "word 1", "...

Get file size from a URL in Swift 3 [duplicate]

I'm developing an ios application and I need your help to get size of files hosted on a remote web server. When my app starts for the first time, it downloads different files in the user's ...

How to observe in ClassB if an object is created in ClassA?

My Object: //Object to observe struct Text { let savedUserHeader: String let savedUserText: String } ClassA where I create the object: //First Class class A { func somefunc(){ let ...

UITableView didSelect not working in swift 3.0

When i select any row than didselect is not getting called.It's color also changes to blue on selection. but didSelect is not working.Delegate, DataSources and Table outlet are also connected. Here is ...

Why can't I access a ViewController variable inside of a function (Swift3)?

This is driving me insane. This should be the simplest thing in the world, and it is just not working, no matter what I try. What I am trying to do is very simple. There is a text field and a button ...

How do I make a UIImageView fill a UITableViewCell?

This is my first post, so if there is something that I should do differently, please let me know! I'm making a photo app, where the I want the photos to fill the UITaleViewCells, and the Cells to ...

Type 'String.CharacterView.IndexDistance' (aka 'Int') does not conform to protocol 'Sequence'

I am attempting to make a morse code converter in a Swift 3 playground. The function I am using does not successfully initiate the translation process, saying "Type 'String.CharacterView.IndexDistance'...

Table view deletion (swipe-to-delete) not animating

I have an issue with table view deletions. The last section in the table view animates fine, but the others don't. Here's I populate the table view: import UIKit import Firebase var items = [Item]()...

Is it possible to mutate a property/variable directly upon initialization?

I was thinking something in the lines of the code-snippet below which obviously does not work but conveys my intention. This one gives the error message variable used within its own initial value. ...

How to make a button, which adds new row with array data in TableView inside ViewController(they are not separate view controllers!)?

I am making a game using swift, and I want to make a history of answers. But the problem is Xcode tells thread1 exc_bad_instruction when I click button "addResult". Here is the code. Before launching ...

I don't want to extent in CIGaussianBlur of CIFilter

When I apply GaussianBlur, the edge is remained like this case I know the problem that is image size. Blur effect is become bigger than source image. But I don't know how to apply original image size ...

To continue when RTMP returns from the background to the foreground

I use the lf.swift of Camera and Microphone streaming library on iOS swift and nginx-rtmp-module of nginx on Server. I have successfully delivered using lf.swift of RTMP library. However, if you move ...

Use Push Notification payload when App launches via the Notification

I was wondering how I can make use of the payload of a push notification, when the user is launching the app via opening that notification. Is this possible? I want to implement an action which ...

Transfer Firebase Storage Image to Database [on hold]

I have a profile picture stored in my firebase database for each user. Here is the reference: profilePicRef = FIRStorage.storage().reference().child((FIRAuth.auth()?.currentUser.uid)!+"/profile_pic....

SKEmitterNode disappears when added to a new SKScene

I have a SKEmitterNode that's running on a SKScene and I want to move it to the next SKScene without interrupting the particles. Normally I'd do it like the following: let scene: SKScene = GameScene(...

priority of Dispatch Queues in swift 3

I have read the tutorial about GCD and Dispatch Queue in Swift 3 But I'm really confused about the order of synchronous execution and asynchronous execution and main queue and background queue. I ...

round number in swift to produce one int at a time in output

Ok guys, I am in a bit of a dilemma, so I got a collectionview and I am trying to find which image the user is on so i decided to create a variable x which is equal to the collectionviewcontentsize / ...

Server Swift with mongodb manager singleton

I am working on a project using Vapor and Mongodb. Let's say that at a specific route drop.get("user", String.self) { request, user in // ... query Mongodb } I want to query the ...

self nil when calling popToRootViewController - error: _swift_abortRetainUnowned

I'm getting a _swift_abortRetainUnowned error when calling popToRootViewController from within a pushed ViewController. I've checked and self is nil when it shouldn't be... Here is the full error: ...

Find all Twitter followings that have an app

I'm looking at the Twitter api reference but I can't find anything like the me/friends api of facebook. Basically I want to get the list of all of my followings that are using my app. Is there a way ...

Handle multiple unauthorised requests after access token expires

I've searched a lot before I post my question but unfortunately I wasn't able to find a solution to my question. I develop an app that connects to a server that requires authentication using access ...

How do I find a CGPoint that extends the path of a SKSpriteNode in SpriteKit?

I have a game where you shoot asteroids that fall from the top of my screen. I have a system where I record a touch and shoot a projectile towards that point with a SKAction.move() action. ...

Swift 3: Get an action button to trigger a TableView

Good day, I would like a button outside my table view that would trigger showing the table view (TableView text blank at first, then for it to show after I click the action button). All of this ...

Main thread runs asynchronously or synchronously in iOS? please explain with Example

Is Main thread runs asynchronously or synchronously in iOS?Is Main thread runs asynchronously or synchronously in iOS

operator is unused Swift [on hold]

I have a UIbutton inside a function and I'm calling to hide it if a textfield is empty. but I keep getting this warning that operator '==' is unused. How can I resolve this. if textfield == ""{ ...

I have to allow user to login by application through Facebook, instagram or google account

I have to allow user to login by application through Facebook, instagram or google account. How to achieve this in my application ?

Why does a UICollectionView not set isSelected to false for a cell that has isSelected set to true in cellForItemAt? [duplicate]

I'm working with a UICollectionView with the default selection rules (single selection only). In my custom UICollectionViewCell class, I've overridden isSelected like so: override var isSelected: ...

Swift3.0 how to set user login state for app launch? [on hold]

In basic project, we use UserDefaults to store the user login state, and save most properties. We also use singleton for sharedUser. For the first time when user login, we save them. When user reopen ...
Translating... 0%