Questions tagged [swift2]

Use this tag only for questions directly related to changes in version 2.x of Apple's Swift programming language. Use the tag [swift] for more general language questions, or the tags [ios], [cocoa], [apple-watch] etc for questions about developing on Apple platforms.

Filter by
Sorted by
Tagged with
1 vote
1 answer
52 views

New To Swift, Having Trouble Converting swift 2 to swift 5 manually

I used to mess around a little when I was younger and I built an app that I'm currently trying to fix and then improve upon but I'm having a few issues converting swift 2 to swift 5 and the app won't ...
  • 11
1 vote
1 answer
168 views

Existential Types and Generics with Protocols Logic Swift 2

I am trying to learn to how generics act in Compile and RunTime stages comparing with Protocols. I know how to protocols react with existential types. Protocols are existential types so in compile ...
  • 21
1 vote
1 answer
1k views

Show Quantity label when product is in cart(Swift 5)

When user add the product to cart.The selected product must show the increment and decrement button. and others product should only show the add button. You can check this image The problem is that ...
0 votes
1 answer
191 views

SwiftUI. How do I access/manipulate data between views

This code is not specifically mine but it will show the problem I am having more clearly. It is a part of an expense calculation application. I am having a hard time manipulating data after ...
-1 votes
1 answer
95 views

I mistakenly deleted a file from project navigator and now xcode say no schemes on top left

I am new to swift and I was undoing a bunch of stuff on Main.storyboard. However, I accidentally deleted something from project navigator. Now xcode says no schemes. When I try to manage schemes, I ...
0 votes
1 answer
1k views

Using countrypickerview ,I want to display only the phonecode not the flag in the left side of text field

By default this library displays country flag, country code and phone code . I was able to remove the country code but not the flag . Let cpv = CountryPickerview(frame: CGRect(x: 0, y: 0,width: 120,...
0 votes
1 answer
34 views

Constraining a collection view under a normal UIView

I have an UIView that shows up fine. I am trying to have a collectionView to show up under it. Both elements show up fine when called on their own, but when I call both I get constraining errors. In ...
  • 68
0 votes
1 answer
504 views

Firebase inAppMessaging events not getting captured

i am sending inApp messages from firebase console. messages are getting delivered but i am not able to capture the events from it i.e. dismiss event, impression event, clicked event from it. all the ...
  • 769
3 votes
1 answer
1k views

How to make on Swift-Wkwebview auto fill username and password?

i have one question. I want to make on my application auto fill username password with keychain. Im added Associated Domains on my application but i dont have now which step is needed now for autofill....
-2 votes
1 answer
131 views

why i have to use print((sender as AnyObject).currentTitle!!) to print title and print(sender.currentTitle) not work?

Why when I try to print button title i used print(sender.currentTitel) and isn't working. And this in below it is work: print((sender as AnyObject).currentTitle!!)
2 votes
4 answers
458 views

Get the most closest value of the CGFloat

I am curious if there is a way in swift to achieve the most closest value via their modern api's? For example: let x = [1.2, 3.4, 4.5, 6.7, 8.9] print(x.getClosestValue(3.7) //3.4 I have been ...
  • 2,443
1 vote
0 answers
99 views

Accessibility Focus not being updated on custom control slider when thumb moves

I have a custom slider based of UIControl and the accessibility works as expected except for the focus on voiceover doesn't reflects/updates when the thumb moves to left or right. I have set the trait ...
  • 2,443
-1 votes
1 answer
134 views

Get the user data from firebase cloud-based database and convert into dictionary

I am new to swift and I am trying to get the data from the firebase cloudbase database and trying to assign them in dictionary. I have tried putting them on a dictionary and printing the values but ...
3 votes
1 answer
671 views

String extension for matching regular expression

I have 2 functions written in Swift 2, but Apple forced me to migrate to Swift 4 and I can't fix the functions. extension String { func stringsMatchingRegularExpression(expression: String) -> [...
3 votes
1 answer
887 views

Change sound button image on clicking another button swift 2.2

I am creating a Tableview inside which is Tableviewcell and on cell there is a label and sound button. For each label there is a sound on button click. When I click for the first time on btn1 the ...
-2 votes
1 answer
191 views

How can I translate the following code from Swift 2 to Swift 5?

I believe the following code below is written in Swift 2. How can the syntax be converted to the latest Swift (5)? When using Xcode for conversion, it leaves me with errors like: Extra argument '...
user avatar
0 votes
0 answers
133 views

Initializer for conditional binding must have Optional type, not 'UInt'

func loadRequest() { var url : URL if (self.url?.hasPrefix(localPrefix) == true) { let appDelegate = UIApplication.shared.delegate as! AppDelegate if let port = appDelegate....
  • 53
1 vote
0 answers
171 views

How to install xcode 7 and edit Swift 2.X on macOS Mojave version 10.14.3

In Case, My project is using swift 2.X . Once i installed Xcode 10. Xcode 10 is not available to code swift 2.X. So i have to installed oldest version, i go installed Xcode version 7.X , but not ...
  • 53
0 votes
0 answers
69 views

Swift Story board inside the tableview issue

May i know the what is this design viewController inside the tableview. which type of this code like container view or etc.
-4 votes
2 answers
76 views

UITableView error when converting to Swift 3

Updating an old app from swift 2.2 to swift 4. I have to use swift 3 as a stepping stone. I converted to 3 but come across the following error: Binary operator '==' cannot be applied to operands of ...
0 votes
1 answer
106 views

Cannot subscript a value of type 'JSON' with an index of type '(key: String)'

Can someone help me with the following error ? I made a migration from swift 2 to swift 3 and in my code it gives me the following error: Cannot subscript a value of type 'JSON' with an index of type ...
0 votes
1 answer
112 views

'init' is unavailable: use 'withMemoryRebound(to:Capacity:_)' UnsafeMutablePointer

I want to use this Swift 2 code in Swift 3 and 4: func getLocalIP() -> String { var address = "error" var interfaces : UnsafeMutablePointer<ifaddrs>? = nil var temp_addr : ...
  • 71
0 votes
1 answer
80 views

Code conversion swift 2 --> 3 resulting in binary operator error at index path

Was using Xcode 7 with swift 2. App worked fine. Updated to Xcode 8. It automatically converted code from swift 2 --> swift 3. Now I have a problem with code for my Table view. Error is with this ...
user avatar
-1 votes
1 answer
29 views

Old Mac Software So can't Use Databases (Xcode)(SQL)

I have swift 2.1 and my Xcode is v6 my mac is v10.1.1. I am doing a school project on Xcode code at the moment and I know I can't post the application on the app store so please don't comment on that; ...
1 vote
1 answer
83 views

CornerRadius don't set

I'm trying to round the corners on the UIView in bottom left and bottom right. extension UIView { func roundBottom(raduis: CGFloat){ let maskPath1 = UIBezierPath(roundedRect: bounds, ...
-1 votes
1 answer
57 views

(swift2) Variable is not changing within if statement

The problem I am facing ishat i am unable to update the variable lin. I have tried multipleimes a f:) . To get to the relevode quick 2nd line in the code is where the variable is identified and then ...
user avatar
-3 votes
1 answer
59 views

Add Gesture Recogniser

For some reason the gesture recogniser does not work, it doesn't make the background normal again. How do I fix it so the selector (self.dissmissMenu) works? In View controller: let menu = Menu() @...
user avatar
1 vote
1 answer
795 views

iOS device won't allow to open the app with distribution certificate not expired nor revoked

Our enterprise app was distributed through Fabric Crashlytics Beta but after a year the app won't open from the device. When you tap the icon it will just close. It can't be download also. The ...
0 votes
1 answer
33 views

core data migration issue: storePath cannot be initiated

I tried to migrate some core data code from swift 2 to swift 4. The code is below: /// Removes the existing model store specfied by the receiver. /// /// - returns: A tuple value containing a ...
  • 609
3 votes
0 answers
667 views

Web RTC , video calling can we record remote RTCMediaStream on ios

I am working on WebRTC project, and successfully done with RTCVideo calling, now i need to record remote stream on ios device ,my question is is it feasible without MCU? i already done lots of search ...
-1 votes
1 answer
208 views

How to update swift 2.3 project to latest swift 4

I am having too many cocoapods installed. It shows too many compile time errors. How to solve this? I am new to swift so looking for help. Thanks
  • 99
0 votes
1 answer
222 views

Migrating Alamofire.Request extension from Swift 2 to Swift 3

I'm trying to migrate an extension to Alamofire.Request but am getting the error Cannot call value of non-function type 'HTTPURLResponse?'. I know the compiler thinks I'm referring to the member ...
1 vote
1 answer
60 views

Migrating from Swift 2.3 (xCode 7) --> Swift 4(xCode 9) + Updating Cocoapods

I'm working on iOS app, and the app is currently running on Xcode 7 swift 2.3, and it has cocoa pods dependencies. I'm trying to migrate the app from swift 2 --> swift 4 and update the cocoa pods as ...
0 votes
0 answers
39 views

Ambiguos reference to member subscript error swift 3

I have this: var sesionesDict:[NSString:Sesion]? let s = sesionesDict![Sesion.dateToKey(sDate!)] as NSArray The sDate returns a string, and the console is continuosly saying: Ambiguos reference to ...
-3 votes
2 answers
211 views

Get double hours from double minute in Swift 2

I'm using Swift 2. I have double myMinute and I want to convert it to double hours(myHours). How can I do it? My codes under below let myMinute : Double = 62.0 let myHours : Double = ? I want to ...
4 votes
2 answers
5k views

How to Get the ISO 639-2 country Code on iOS using Swift

Currently I used the following code , but it will return only two digit code if let countryCode = (Locale.current as NSLocale).object(forKey: .countryCode) as? String { print("Code => \(...
0 votes
1 answer
1k views

Swift 2 Object Mapper class append doesn't work, result nil

I'm using Object Mapper in Swift 2 (when I download from api it worked well) but I want to add some objects inside my class with append. It currently doesn't work, i.e. it doesnt add any object. My ...
-5 votes
1 answer
129 views

Swift 2 String Array remove Spesific Index Error

I have String Array; var students = [String]() and my students array output : students[0]:102----3---- students[1]:102-2018.07.24-4--6--- students[2]:103--5--4-- students[3]:34-...
1 vote
1 answer
762 views

How to reload UIPageViewController to reload its views in Swift

I am using Page Controller embeded in Table VC. Table VC shows details of items and also contains collection view controller as embedded one. So now when I select any Collection cell it should ...
0 votes
2 answers
281 views

Migrate to xcode 9 for swift 2.3 apps

I have an app launched in appstore built on Swift 2.3 using Xcode 8, now apple made Xcode 9 mandatory for new and app updates to store Is it must to migrate to Xcode 9? have any one submitted swift 2....
  • 11
0 votes
4 answers
5k views

how to get the index value in dictionary using swift

As I am new to swift programming language .I am using the dictionary of two items now i need to take the index path of particular dictionary value .I am using the following code var dictionaryitems =...
  • 131
0 votes
1 answer
67 views

Apple Mach-O Linker (ld) Error swift 3.0 and Xcode 8.3.3

I am getting Apple Mach-O Linker (ld) Error (clang: error: linker command failed with exit code 1 (use -v to see invocation)) . I just moved my code from swift 2.3 to swift 3.0. I am using pods. And ...
12 votes
2 answers
20k views

Open web url link in browser in Swift

I want to load webpage that link I fetched through web service. I have tried myself but result is not in favour. From server I was getting this kind of url: http://www.simrishamn.se/sv/kultur_fritid/...
  • 4,092
0 votes
0 answers
346 views

Cannot convert value of type String to specified type NSManagedObjectContext Swift 4

I need Help. While conversion from Swift 2.3 -> 3.2 I received below error. I'm not able to resolve this error. Error : Cannot convert value of type String to specified type NSManagedObjectContext ...
  • 3
0 votes
2 answers
876 views

Cannot convert value of type String to specified type NSManagedObjectContext, While converting from Swift 2.3 -> 3.2

I need Help. While conversion from Swift 2.3 -> 3.2 I received below error. I'm not able to resolve this error. Below is my coding stuff, where I'm facing some issues. Error1 : Cannot convert ...
user avatar
0 votes
2 answers
854 views

Cannot subscript a value of type NSDictionary with an index of type String. While converting from Swift 2.3 -> 3.2

I need Help. While conversion from Swift 2.3 -> 3.2 I received below error. I'm not able to resolve this error. Below is my coding stuff, where I'm facing some issues. Error : Cannot ...
1 vote
1 answer
141 views

Change code from Swift 2 to swift 4

I'm new in Swift and i want your help please. I am writing a code from an tutorial swift 2 and i want to write in swift 4. let imgManager = PHImageManager.default() let requestOptions = ...
0 votes
1 answer
178 views

Alternative to .trimmingCharacters to get my solution accepted by Coderbytes

On my Xcode playground the following snippet trims the whitespaces from any String (as I want). let trimmed = " hello ".trimmingCharacters(in: .whitespaces) When I try to submit a solution using ...
0 votes
0 answers
62 views

Parse from JSON html string in Swift 2.3

My data below is printing HTML tags let usernameRAW = json["username"] as? String self.username = (usernameRAW)! print("Username: \(self.username )") It's showing some HTML tags from JSON data. ...
0 votes
0 answers
137 views

How to add array of dictionaries from NSArray to Existing NSMutableArray in swift?

In my project I have one NSMutableArray and NSArray named logOrderMutArray and openOrderArray, here I want to merge the openOrderArray with logOrderMutArray based on same "AccountNumber". If ...

1
2 3 4 5
178