Questions tagged [swift4]

2

votes
0

answer
45

Views

Trouble formatting jsonObject

let jsonResult = try JSONSerialization.jsonObject(with: jsonData, options: JSONSerialization.ReadingOptions.mutableContainers) as! [String : Any] let jsonString = jsonResult.map { return ($0.key, '\($0.value)' == '' || '\($0.value)' == 'nil' ? 'null' : '\($0.value)') } httpPOST(to: '\(postURL)/proc...
tchen2
0

votes
0

answer
221

Views

IOS Mapview set region crashing

My application is crashing self.mapView.setRegion method when I'm trying to set the region for the map view. I will get the location details from API like longitude, latitude, accuracy. { 'latitude': -96.790127, 'longitude': 32.782054, 'bearing': 233, 'altitude': 23423, 'accuracy': 20 } I want to s...
0

votes
0

answer
16

Views

Trying to select individual CAShapeLayer

I'm trying to add CAShapeLayer to UIView.layer. I want the user to be able to select and deselect shapes by tapping them or swiping over them. Then I can display how many shapes are selected. Below I've got code where I add circles to the screen in the add circles method which works as I'm intendin...
StartPlayer
0

votes
0

answer
35

Views

“Phantom classes/Models” still appearing in Realm

I'm going mental trying to work this out. I had 2 old classes which are no longer used in my code. I'm trying to get rid of them in my Realm. I have tried a migration and a delete and restart and they just keep coming back (they don't have any objects in but it's untidy and annoying!) I've tried t...
nc14
0

votes
0

answer
8

Views

Swift 4 tableView API Pagination

I have successfully parsed JSON data and displayed only the first page on my tableview. I don't know how I would set up pagination with the api and display the rest of the data when I scroll down on the tableView. The API I'm using is https://rickandmortyapi.com/api/character/. Thank you for all you...
Aaron Treinish
4

votes
0

answer
62

Views

AES Decryption in SWIFT4 Producing null Value

I'm using an extension method to decrypt a string which is encrypted by the server side php script using AES Algorithm. The following is the extension method used func aesDecrypt(key:String, iv:String, options:Int = kCCOptionPKCS7Padding) -> String? { if let keyData = key.data(using: String.Encoding...
techno
2

votes
0

answer
51

Views

AKOscillator in 4.1 sounding VERY different than 4.0.4

Has something radically changed in AKOscillator or AKAmplitudeEnvelope 4.1? My code for a simple chime sound worked like a charm in 4.0 but is now some kind of weird alien thing in 4.1. I am not sure how to proceed without going back to 4.0. Here is my code for setting and playing a note: var os...
WholeCheese
4

votes
0

answer
3.9k

Views

Use of @objc inference in Swift 4 [duplicate]

This question already has an answer here: The use of Swift 3 @objc inference in Swift 4 mode is deprecated? 9 answers How can I deal with @objc inference deprecation with #selector() in Swift 4? 4 answers I am getting this warning: Argument of '#selector' refers to instance method 'customButtonDi...
pesch
2

votes
0

answer
419

Views

Check local file size in Swift 4

I have this code: func fileSize(url: String?)-> UInt64 { let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) guard let fileUrl = URL(string: url!) else { print('Problem in converting string to URL @@@@@@@@@@@ \(url)') return 0 } let directory = paths[0] + '/'...
triff
2

votes
0

answer
89

Views

Mouse Location in Playgrounds in Swift 4

I'm trying to create an event handler (or anything else that works at this point) to grab the cursor location inside an Xcode Playground Live View. I know this has been possible in the past, specifically with this WWDC Submission here: https://www.youtube.com/watch?v=Gb4ZLPCiuzE My naive approach wa...
Ankush Girotra
2

votes
0

answer
170

Views

Music App Now Playing View Controller Slide In Animation

I've been trying to recreate the animation and swiping functionality used in the music app, and trying to re-create the card view structure they use. I was wondering if anyone has done this before, or knew how apple accomplished the swipe in, swipe out features and animations. It's very responsive,...
Sulaiman Majeed
4

votes
0

answer
995

Views

How to programmatically open the Bluetooth settings in iOS 11

Code that I used for iOS 10 no longer works on iOS 11... Any ideas what to change? I need to open Bluetooth Settings not general iOS Settings that is getting opened by code below if let settings = URL(string: 'App-Prefs:root=Bluetooth') { UIApplication.shared.open(settings, options:[:], completionHa...
Maksim Kniazev
4

votes
0

answer
1.8k

Views

Cannot conform to Decodable or Encodable (Using Codable) even when object used conform itself

I'm having some trouble with conforming 2 protocols together using the Codable protocol. My understanding is that even if I used a custom object, as long as that object successfully conforms to Codable, then any object referencing that can also conform. I have the following code and cannot see why I...
SamRowley
4

votes
0

answer
405

Views

add download button for pdf in wkwebview in swift 4

I have done webview app using wkwebiew in xcode 9. In the website, there are some part need to download the pdf file, the pdf file can be view only but how to make it can be download to our iphone. can you share some tip to me, this is my code class ViewController: UIViewController,WKNavigationDeleg...
Mr White
2

votes
0

answer
647

Views

Swift integration issue in Xcode 9?

I am working on an Application written in Swift. I added Objective-C classes. I have done every thing described here, Now i can use all my Objective-C classes in Swift files but can't access Swift files in Objective-C classes. Even I can't import the file 'MyProjectName-Swift.h' in my Objective-C cl...
Nisar Ahmad
5

votes
0

answer
392

Views

Refresh Controller with navigationBar that has prefersLargeTitles set to true

I am using a navigation controller and within that navigation controller, I have a VC with a tableview that is hugging the top, bottom, left and right sides of the superView. When I have self.navigationController?.navigationBar.prefersLargeTitles set to false, everything works fine. But when I set i...
Nevin Jethmalani
8

votes
0

answer
738

Views

Swift 4 with iOS 8

After updating my code to Swift4 , app is getting crash on iOS 8.3. I am getting following error dyld: Symbol not found: _NSCharacterEncodingDocumentOption Referenced from: /private/var/mobile/Containers/Bundle/Application/213D60CD-1ED9-4811-A3C7-B47383557453/development.app/development Expected i...
Aashish Nagar
0

votes
0

answer
6

Views

setting constraints on Lottie animation- swift

I am new to coding in swift (and new to coding in general) - and struggling with applying constraints to Lottie animation. I was able to get it to center on the screen- but cant get the animation frame to change its size according to the screen size- keeping it's aspect ratio. at the moment the si...
Roy Perez
-2

votes
0

answer
14

Views

Make an API call even if internet is not available

So I'm working on an IoT app, where I need to configure the hardware by connecting to its WiFi. If I use AFNetworking or URLSession to make the call, they fail with this error message. 'The Internet connection appears to be offline.' I need a way to make the API call to the local Wifi of the hardwar...
danialzahid94
0

votes
0

answer
4

Views

Apple/iOS pdfkit who i create dropdownlist and how i give default values on forms?

I use this code to create a form on the pdf: // Intro: 'Text2' let text2FieldNameBounds = CGRect(x: 153, y: pageBounds.size.height - 379, width: 427, height: 20) let text2FieldName = PDFAnnotation(bounds: text2FieldNameBounds, forType: PDFAnnotationSubtype(rawValue: PDFAnnotationSubtype.widget.rawVa...
Thomas Boz
-1

votes
0

answer
6

Views

Fetching And Parsing Data From Json Api In Faster Way in Swift

I working on a IOS project based on json API totally. I have completed my project almost but i have an issue regarding json API response rate, it is very slow and it takes time to load data in tableview. I am looking for a best way to fetch or parse data or load data in tableview quickly or faster....
hussnain ahmad
1

votes
0

answer
29

Views

iOS | Tapping on Marker Zooms out Google Map SDK

I have a GMSMapView instance, orderMapView, which is linked to my UIViewController. I give Location Permissions and later make self as delegate of orderMapView orderMapView.delegate = self I also make the class conform to GMSMapViewDelegate. I then initiate multiple markers in viewDidLoad, one of wh...
1

votes
0

answer
29

Views

Multipart Video Upload from iOS takes too long. The same video posted from android is fine

I am trying to upload a video file from multipart upload, what happens is the video takes a long time(3.5 minutes) to be submitted. The file size is max around 18 to 20 mb. Also if a video is submitted in parallel from a different device simultaneously then the upload is stuck forever. I have given...
Kumar Gaurav
1

votes
0

answer
48

Views

Unable to update NSTouchBar programmatically

I am currently developing a very simple Live Scores MAC OSX app for personal use where I show a bunch of labels (scores) on the touch bar. What I am trying to achieve in a few steps: Fetch live soccer scores from a 3rd party API every 30 seconds Parse the scores and make them into labels Update the...
kb_14
1

votes
0

answer
291

Views

Contact form swift 4 without using default mail.

So I made a contact form in my app, it has it’s own ViewController. I have 3 text fields and 1 send button. I have it working good but i could only find tutorials to have it just open up the default mail composer with the message area filled with the info from the textfields. My question is, is th...
Manuel Duarte
1

votes
0

answer
115

Views

how can enable the zoom in uiwebview using swift without using the scalesPageToFit=true property because it cause Sequese webview

I want to enable the zoom in zoom out functionality on UIWebView using swift. I've applied the following and all help available on stack over flow and others. I dont want to use the scalesPageToFit functionality provided by apple when I use scalesPageToFit = true the zoom in zoom out functionality s...
dev6
1

votes
0

answer
360

Views

Did Select method in Table View not Working in Swift

I'm using two table view in one view controller to populate my different data. All the other delegates methods are working fine but didselect method is not performing an action neither its printing any value in console. I hae checked through story board also all the things looks fine and i have set...
Hamza
1

votes
0

answer
310

Views

Dont animate navigationBar transition when push ViewController with SearchController and before in navigation were too a VC with SearchController

i have problem with animation of navigation bar when pushing other view controller also with UISearchController to navigation controller. If i push ViewController without SearchController everything is OK. The problem can be seen when on the screen with UITableView scroll down for display UISearchCo...
Martin Matějka
1

votes
0

answer
157

Views

Bundle.main.bundleIdentifier returns nil

Anybody can tell me when is the case where Bundle.main.bundleIdentifier will returns nil? if let domain = Bundle.main.bundleIdentifier { UserDefaults.standard.removePersistentDomain(forName: domain) } With the code above, there are 'random cases' where UserDefault was not cleared so I can only assum...
SquareBox
1

votes
0

answer
2.3k

Views

How to Check Bluetooth ON/OFF in iOS 11+ in swift

Here is my Code! I Have iOS 11+, swift 4+, CoreBluetooth Framework while I'm running my application it always shows Bluetooth is Off.but I run the same code in below iOS 10 version its runs how its happening? My priority is to run on iOS 11+ what should I do? any suggestion??? import UIKit import...
Mohammed Fazil
1

votes
0

answer
32

Views

Firebase clousure is skipping itself for no reason

I am trying to observe single event via firebase. The address is correct there is no mistake that I am aware of. Please help me out. It skips whole code that is posted below. Database.database().reference().child('users').child(messagesWithId[indexPath.row]).child('metadata').observeSingleEvent(of:...
Jason Krowl
1

votes
0

answer
77

Views

How to record video of a filtered UIImageView in Swift?

I have my camera's output going through a UIImageView's image so that a filter effect can be applied to it in real time. How do I capture the video output that I'm seeing in real time? I want to start recording for as long as I want, then stop the recording and have the resulting video stored somewh...
Chewie The Chorkie
1

votes
0

answer
70

Views

SKSpriteNode Custom Class and accessing variables from another class

In GameScene.sks I have created a Color Sprite with a Texture and provided a Name “hero”, within the Custom Class tab I have put “CharacterNode” class. In a file “CharacterNode.swift” (the Character class), I just hold BOOL properties relating to the hero (e.g. walkLeft, walkRight, actio...
JohnL
1

votes
0

answer
1k

Views

Facebook login in iOS (Swift 4) - Get permissions and store in Firebase

I've found some good resources on Stackoverflow and youtube helping getting around the fact that the Facebook iOS SDK descriptions are not up to date. I've now successfully managed to create the Facebook login feature and a new user is registered in Firebase. However my current issue is two fold. 1...
Chris_1983_Norway
1

votes
0

answer
29

Views

Efficiently pass core data objects to common detailViewController

I have a number of entities that describe different pieces of equipment. I read these into the EquipmentViewController. I'm struggling to figure how to use a generic EquipmentDetailViewController that can be used to show and update any of the different entities. I have it working by having a separat...
David DelMonte
1

votes
0

answer
235

Views

After adding and updating sticky with stretchy header in tableView, its scroll becomes jerky

I am developing a custom tableView with stretchy headerView and it also has sticky headerView. I have successfully achieved it by updating its contentInset and contentOffset properties. But after updating its contentInset the scroll becomes jerky. Below is the code for the same: I have added below c...
Akruti
1

votes
0

answer
957

Views

Making a HTTP POST request in Swift 4

I´m trying to send data to a PHP file on my server using URLSession. This seems to fail though, since no data is received on the server. While running the app, I get this console print: 2018-01-09 20:56:10.942359+0100 EinsatzPush[12182:8624757] [BoringSSL] Function boringssl_session_errorlog: line...
Nils
1

votes
0

answer
72

Views

set main/ root page in TabBarController Swift 4

I'm still new in IOS development(Swift) and using storyboard. I have a TabBarController that has 3 tab bar items that already embed with ViewControllers on it. I have added a back button on each view controller. I want to add a main/root page to the TabBarController without adding the tab bar item...
madhatter989
1

votes
0

answer
39

Views

Accessing resting heart rate

Good Day, I'm a novice at Swift 4 and am having a trouble getting resting heart rate data. Here is what I have: // Declarations var heartRateType = HKAnchoredObjectQuery.self private func createStreamingQuery() -> HKQuery { let calendar = NSCalendar.current; let now = NSDate(); let sevenDaysAgo = c...
kdcattran
1

votes
0

answer
260

Views

iOS Swift - PHPhotoLibrary The operation couldn’t be completed. (Cocoa error -1.)

I'm trying to save a video file to photo library. I got the following code snippet working, but I'm getting weird cocoa error -1 when trying to save a video created using UIImages with text added programmatically. What is causing PHPhotoLibrary error 'The operation couldn’t be completed. (Cocoa...
Alex Stone