Newest swift Questions

Q&A for professional and enthusiast programmers

Give some idea about the below code? CollectionView inside the Tableview returns same data?

Step1: I created the tableview and custom tableview cell here is the code.** Structure class: struct DashSection { var heading : String var titles : [String] var images : [String] init(title : ...

How can I use switch statement to implement collectionView function in Swift?

I am new to swift and trying to implement collectionView function in a ViewController.Now I have three types of UICollectionViewCell,here is my code: func collectionView(_ collectionView: ...

Swift 3 - Program crashes when trying to perform fetch request

currently, I'm trying to fetch an entity of type song on one of my view controllers. this is the code that's relevant, that I have: import CoreData class TimerScreenVC: UIViewController, ...

Swift - Is there any Rich Text Editor (WYSIWYG) Library for iOS apps?

I'm looking for a rich text editor written is Swift. I only found an old one here, written in objective-c Thanks

RTSP live stream on iOS

I am trying to implement an iOS app that supports HTTP and RTSP live stream. I have setup a RTSP live camera but I don't know how to show it on the iPhone. Is RTSP even supported by the iOS SDK and ...

Scroll UITableView to bottom when keyboard appears using inputAccessoryView and Stop calling keyboardWillShow twice

What I am doing: Creating a application where user inputs any data and store it into UITableView I am using UIViewController NOT UITableViewController What I am trying to achieve: When user open ...

UITextView/UITextField: How to check if a delete key is pressed in Swift

As the title in this question. I want to check if delete key is pressed. I knew about this code below: func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, ...

Intercept paste action in Swift

Is there a way in Swift to get the pasted content before it is pasted? Ideally I should be to read the to be pasted content when user selects 'paste' from the default pop-up menu in an editable ...

NSCollectionViewItem messed after reloadData

Im working with NSCollectionView and NSCollectionViewItems. I have met following problem: If I rotate an NSImageView of one of the items, and then call reloadData, updated view would be messed up. ...

What is the best way to keep association between 2 specific managed objects from different tables(entities) with Core Data?

In my app I have 2 entities: Project: projectId: Int64 title: String? address: String? startDate: Date endDate: Date ... User: userId: Int64 email: String? firstName: String? lastName: String? ...

Ios swift camera image picker rotate issue

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {} image retrived from above code will rotate image 90 degree ...

How to make i pad app for All Screen

I am making an iPad app My app runs in all iPad screens fine but it is not working properly in iPad pro (12.9inch) i know it can be solved by autolayout but, is there any other way to solve it ...

check is a value matches a list of array elements and retrieve value

I have an array array of custom data in Swift. I'd like to find the object that contains value of dictionaries whose "Destination" equals to the 'PlaceId' in second array. let flightsArray = [ "Name"...

Can a View Controller inside a PageViewController animate upwards when Swipe Gesture Up is done by the user?

I have a UIPageViewController, with a couple of view controllers inside. It is currently horizontal scrolling and I've added a swipeUp gesture to the view itself. var swipeUp = ...

iOS Could not get new touchEvent when touch two view with same parent view under a Same ViewController

Here I have view like this pic A,B was addSubView to C, C add SubView to D ViewController's View, I override D ViewController's touchxx functions (like touchesBegan..),And first I touch Area A and ...

Swift package manager for objective c code

I have few old objective c projects which has to be converted to a framework for usage across existing and new xcodeproj. Will SPM be a good choice ? Please let me know if SPM work for a pure ...

Persist UITableViewCell background color on scrolling tableViewCells

I have a UITableView, when the user taps a cell it turns grey to indicate it is complete. However when the cell is scrolled out of view, when it comes back into view it has returned to its default ...

core data and relationship predicate

I've start swift & core data few month ago usually I've found my answer on this website but for the first time I'm really stuck with "Relationship" and "Predicates" I've created a first view ...

MouseDown Event prevent NSCollectionView Delegate Methods

I would like to implement an action by double clicking an item within a NSCollectionView. When using the mouseDownevent in the NSCollectionViewItem no collection view delegate method is fired anymore ...

UIImage created doesn't appear as I would have expected?

iOS 10.2 swift 3.0 I am using these routines to cut, resize and recombine an image to display on an AppleTV. But despite the fact it reports the image as the correct size, it doesn't work the way I ...

Using only one AVAudioPlayer instead of three

I created three AVAudioPlayer, each plays an audio file. While the audio is playing the UIButton is set selected by audioPlayerDidFinishPlaying. Insted of using three different AVAudioPlayer, I would ...

LongPolling With rxSwift

I studying rxSwift, and I want to do service for the interaction of c longpolling server to this service imitating a permanent connection. I wrote it, but it seems to me, is not that the decision ...

Dragging items while in a UIPageViewController

I have put together a set of pages using UIPageViewController. The first screen is an initial screen, and the user should swipe to the next page after being greeted. The following three screens are ...

How to switch for dynamic enum type that's optional? [duplicate]

enum AnimalType { case dog case cat } func feed(actions: [String : Any], animalType: AnimalType, dontFeedType: AnimalType? = nil) { let animalTypeToFeed = find(actions: actions) ...

How can I convert these doubles to integers on this iOS Bar Chart? [duplicate]

I want to convert these doubles to integers on this graph below: I have followed the advice of other posts and created a YAxisValueFormatter() that implements IAxisValueFormatter but this doesn't ...

IBM Bluemix - Kitura Swift - is missing a required environment variable: 'OPENAPI_SPEC'

I am stuck for the moment. I cannot obtain the source code for the mobile project and I do not know where is the problem. All my researches was without positive result. My intention with IBM Bluemix ...

Image doesn't fit properly in swift

My gui looks like that: http://i65.tinypic.com/6fxxzt.png The four imageviews must fill the whole screen so I don't know how to change the images. I tried to set the contentMode to setAspectFill and ...

terminate app after opening safari - swift

I have a button in my app that opens a link via safari. There are some tasks user does in web and finally returns to app on pressing a button in browser. what I need to do is to terminate app when ...

Developing a “meet me” app

I am currently working on an application where I want users to be able to meet up using maps. I want this to happen by being able to browse user profiles, deciding they want to meet them and then once ...

How to get live value from CoreData Or know if value is change from last fetch value in iOS Swift?

I am fetching value from Coredata and showing it in a UItableView but after showing values in UITableView there are few values are updated by another thread. Now want know a way to reflect those ...

IOS decline incoming call programmatically?

Is there any way decline a incoming call programmatically in swift. My code like this: self.callCenter.callEventHandler = {(_ call: CTCall) -> Void in if call.callState == ...

Swift: Split view controller on universal app that isnt initial view controller

I have a universal app and want to add a split view controller for my settings view only. This means that I require a split view controller that isnt the initial view controller which would handle the ...

Is there a decltype equivalent in Swift?

In C++11 and latter, it is possible to use a compile time function like syntax named decltype() to reuse declaration type of a variable to declare another one without rewriting the type signature. Is ...

Issue when trying to retrieve data from Firebase with Swift 3

I'm trying to retrieve data from my Firebase database. I use JSON to get the data. Using SwiftyJSON library. Here is my code: func retrieveUserDatabaseAdress(userID: String) { let userRef = ...

Having trouble with the Tab bar background image

I would like to show the background image for the tab bar which is having vertical separator lines. I have this images in the following resolutions:- 1x - 320 x 49 2x - 640 x 98 3x - 960 x 147 ...

Swift Reduce - Add Int Values of Strings

I have an array ZZ of custom object A with property: String a1 I would like to add the a1 property of all the elements in the array and return an NSNumber value. Since the value a1 is a string, I ...

“dataTaskWithRequest” requests the NSMutableRequest twice when only one request is required

I have a secure webView which shows the customer to Load his wallet . I pass secure information MPIN(like a one time password). There is problem with let task = NSURLSession.sharedSession()....

af_setImage - unexpectedly found nil while unwrapping an Optional value

I want to load my images from sever side, but af_setImage show me this error : fatal error: unexpectedly found nil while unwrapping an Optional value my code : override func collectionView(_ ...

Printing item too big

This is how I'm printing an image at the moment: let printInfo = UIPrintInfo(dictionary: nil) printInfo.outputType = .photo let printController = UIPrintInteractionController.shared ...

Reciving userInfo as a message using FCM swift 3

Is it the way to recognize the content in the message ? Example : Firebase -> send your first notification. Text : John Canna, 20 And in the code I would like to get these informations and sign ...

Function to Unfriend Twitter Returns Optional Error

So, here I have a function to unfriend a user displayed in a table. It uses the loop statement at the beginning to get the index of user and follows accordingly. Only, it returns and error indicating ...

Reject transaction at StoreKit

Apple suggest to use SKPaymentQueue.default().finishTransaction(transaction) only when App provided functionality. So, in case when transactionStatus == .purchased I’ sending request to my backend. ...

How to show a search bar and when click put it in navigation item?

I'm not too good on naming questions, so, any edit to help for it will be nice. Anyway, I'm trying to achieve the same as the Message (SMS) iPhone app. When you open the app, it shows a search bar ...

Cannot convert return expression of type Int to Int

I wonder why this is not work: func removingOnce (_ item: Int, from array:[Int]) -> [Int]{ var intToReturn :Int? intToReturn = 0 for ob in array5{ if (ob == item){ intToReturn = item ...

How to reopen application after login

I'm an android developer. in android, when user login in application, I will re-open the MainActivity class ( controller ) to refresh some views. in iOS applications, how to do this scenario ?

calculate distance between postcode in swift 3

im working on an app which will, well, needs to be calculating a distance from postcode a to postcode b. the user is giving the last postcode from the current location, postcode b. the first location ...

MVVM tableviewcell return nil

I'm trying to make an mvvm integration on a tableViewController, however I keep getting fatal error: unexpectedly found nil while unwrapping an Optional value on super.init(style: style, ...

pass the data from uitableview to other uiview

I'm new in swift and IOS, i have some problem to pass the dictionary data to other uiview, anyone can help me to fix it? LessonsTableViewController: var mylessons = [ ["title":"Posture", "...

How to create Model class in Objective C++?

I want to make Model class in objective c++ which contains Name & Email id. Like what we do in Swift 3 ex:- import UIKit class modelDemo: NSObject { var name : String = "" var emailId :...

Xcode 8 - Framework not found -sqlite3

I integrated animation with Quartzcode, it's work fine but when I launch Xcode, since this modification, xcode crash on signin product step ( before build ). I have some pods installed for this ...
Translating... 0%