# Swift

**URL:** https://forums.kodeco.com/c/general/swift/15.md?page=25

[Latest](https://forums.kodeco.com/latest.md) · [Categories](https://forums.kodeco.com/categories.md) · [Tags](https://forums.kodeco.com/tags.md)

**Page:** 26

---

## [Sort struct by alphabetical order then descending int order](https://forums.kodeco.com/t/sort-struct-by-alphabetical-order-then-descending-int-order/35416)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 2\
**Last updated:** [October 25, 2017, 6:59am UTC](https://forums.kodeco.com/t/sort-struct-by-alphabetical-order-then-descending-int-order/35416 "2017-10-25T06:59:38Z")

</div>

My code below sorts the struct in alphabetical order. However I would like code the code to be sort in alphabetical order first then by descending int order. For example joe, 3; joe 4. (contacts.sorted {$0.descri…

---

## [Print top 2 highest scores in dictonary](https://forums.kodeco.com/t/print-top-2-highest-scores-in-dictonary/35224)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 2\
**Last updated:** [October 25, 2017, 6:57am UTC](https://forums.kodeco.com/t/print-top-2-highest-scores-in-dictonary/35224 "2017-10-25T06:57:44Z")

</div>

The code prints out the highest score in the dictionary. How can I print the 2nd highest score as well. I want to print the top 2 scores. import UIKit var people: \[\[String:Any\]\] = \[ \[ "firstName": "Sam", "…

---

## [Login Google SignIn](https://forums.kodeco.com/t/login-google-signin/35541)

<div class="topic-metadata">

**Author:** [@jack7](https://forums.kodeco.com/u/jack7)\
**Replies:** 1\
**Last updated:** [October 25, 2017, 6:48am UTC](https://forums.kodeco.com/t/login-google-signin/35541 "2017-10-25T06:48:33Z")

</div>

Hi, I need to log in with Google Sign-In for iOS. My App is both in Obj-C and Swift. The login viewcontroller is in Swift, but the AppDelegate is in Obj-C. I followed the guide of Google: I have imported the library …

---

## [Struct not keeping sorted order (swift4)](https://forums.kodeco.com/t/struct-not-keeping-sorted-order-swift4/35060)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 1\
**Last updated:** [October 25, 2017, 6:45am UTC](https://forums.kodeco.com/t/struct-not-keeping-sorted-order-swift4/35060 "2017-10-25T06:45:05Z")

</div>

My code has 2 textfields one for int and the other for string. The way the code is supposed to be sorted is by ascending alphabetical order for the string (a-z)then by descending order for the int (9-1).So i entered 2 en…

---

## [How to save entry to struct (swift4)](https://forums.kodeco.com/t/how-to-save-entry-to-struct-swift4/35290)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 1\
**Last updated:** [October 25, 2017, 6:32am UTC](https://forums.kodeco.com/t/how-to-save-entry-to-struct-swift4/35290 "2017-10-25T06:32:52Z")

</div>

Right now my code prints the struct that was entered, but it can only print the last individual entry entered. It can only store 1 entry. How can I store and print every entry in the struct. import UIKi…

---

## [Certificate Signing Request(CSR) in swift using Secure Enclave](https://forums.kodeco.com/t/certificate-signing-request-csr-in-swift-using-secure-enclave/14836)

<div class="topic-metadata">

**Author:** [@cheetah2000](https://forums.kodeco.com/u/cheetah2000)\
**Replies:** 2\
**Last updated:** [October 11, 2017, 4:17pm UTC](https://forums.kodeco.com/t/certificate-signing-request-csr-in-swift-using-secure-enclave/14836 "2017-10-11T16:17:24Z")

</div>

I am looking for help to write the certificate signing request in swift. I am able to create a keys(private & public) in the secure enclave and able to access through keychain. Just, looking help for certificate signing …

---

## [How to remove \[\] from print struct](https://forums.kodeco.com/t/how-to-remove-from-print-struct/35357)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 2\
**Last updated:** [October 9, 2017, 8:36pm UTC](https://forums.kodeco.com/t/how-to-remove-from-print-struct/35357 "2017-10-09T20:36:08Z")

</div>

My Code below prints a struct its how I want it expect for the \[\]. I just want it removed. var contacts = \[Person\]() @IBAction func press(\_ sender: Any) { contacts.append(Person(name: a.text!, ph…

---

## [PresentationController with AutoLayout](https://forums.kodeco.com/t/presentationcontroller-with-autolayout/35260)

<div class="topic-metadata">

**Author:** [@thenerd\_be](https://forums.kodeco.com/u/thenerd_be)\
**Replies:** 2\
**Last updated:** [October 6, 2017, 6:34am UTC](https://forums.kodeco.com/t/presentationcontroller-with-autolayout/35260 "2017-10-06T06:34:07Z")

</div>

Hi all, I’m trying to create a custom presentationcontroller, but I’m having the following issue. The view controller that is presented, should slide in from the bottom and only cover a part of the screen (like the App…

---

## [New Xcode 9 Simulator is very slow](https://forums.kodeco.com/t/new-xcode-9-simulator-is-very-slow/34677)

<div class="topic-metadata">

**Author:** [@henkyboy89](https://forums.kodeco.com/u/henkyboy89)\
**Replies:** 5\
**Last updated:** [October 4, 2017, 11:55pm UTC](https://forums.kodeco.com/t/new-xcode-9-simulator-is-very-slow/34677 "2017-10-04T23:55:30Z")

</div>

Hello, i am new to Xcode and new to Swift :slight\_smile: Since the new update I have really bad Performance on the Simulator no matter which device i choose. I tried to learn Swift with the Book 2D Apple Games and I am …

---

## [Reward system in Swift](https://forums.kodeco.com/t/reward-system-in-swift/35151)

<div class="topic-metadata">

**Author:** [@mah927](https://forums.kodeco.com/u/mah927)\
**Replies:** 1\
**Last updated:** [October 4, 2017, 5:24pm UTC](https://forums.kodeco.com/t/reward-system-in-swift/35151 "2017-10-04T17:24:30Z")

</div>

I am trying to set up a reward system. Basically, I would like to reward with coins for: Sharing the game with friends Watching an add Reviewing the game The user can purchase new artifacts with these coins. How do I …

---

## [How to get current date from server not from device](https://forums.kodeco.com/t/how-to-get-current-date-from-server-not-from-device/35085)

<div class="topic-metadata">

**Author:** [@minnesota](https://forums.kodeco.com/u/minnesota)\
**Replies:** 2\
**Last updated:** [October 2, 2017, 6:12pm UTC](https://forums.kodeco.com/t/how-to-get-current-date-from-server-not-from-device/35085 "2017-10-02T18:12:54Z")

</div>

Hello, I need the app (game) to check on launch what date it is today. I can’t get it from device because users can manipulate it. I know nothing about servers and Swift is my first language that I learned (big thanks …

---

## [Google place tutorial in swift](https://forums.kodeco.com/t/google-place-tutorial-in-swift/35052)

<div class="topic-metadata">

**Author:** [@kadaram](https://forums.kodeco.com/u/kadaram)\
**Replies:** 0\
**Last updated:** [October 1, 2017, 4:03pm UTC](https://forums.kodeco.com/t/google-place-tutorial-in-swift/35052 "2017-10-01T16:03:23Z")

</div>

Hello guys, i followed here on raywenderlich the iOS tutorial to add the Google Places API on my project, the tutorial is old and is structured for not have a direct usage of the service from the mobile app but with my …

---

## [Wireless Access point](https://forums.kodeco.com/t/wireless-access-point/34828)

<div class="topic-metadata">

**Author:** [@aliq52](https://forums.kodeco.com/u/aliq52)\
**Replies:** 2\
**Last updated:** [September 30, 2017, 6:53pm UTC](https://forums.kodeco.com/t/wireless-access-point/34828 "2017-09-30T18:53:15Z")

</div>

Hey, So i have two questions, Q1) Can i differentiate between two AP’s in my code by getting there BSSID or MAC Address? (the AP’s have the same name.) Q2) Can i switch AP’s from within my code? (for e.g. when signal …

---

## [Userdefualt is not applying to struct](https://forums.kodeco.com/t/userdefualt-is-not-applying-to-struct/34976)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 6\
**Last updated:** [September 29, 2017, 10:28pm UTC](https://forums.kodeco.com/t/userdefualt-is-not-applying-to-struct/34976 "2017-09-29T22:28:07Z")

</div>

I would like whatever is in the textfield when the user hits the button to be added to the struct. The problem is that on the twoViewcontrolelr only one entry is being displayed at a time. I am trying to create a list w…

---

## [Possible to build a gui using swift package manager as the build system?](https://forums.kodeco.com/t/possible-to-build-a-gui-using-swift-package-manager-as-the-build-system/34454)

<div class="topic-metadata">

**Author:** [@jmoyers](https://forums.kodeco.com/u/jmoyers)\
**Replies:** 4\
**Last updated:** [September 29, 2017, 9:16pm UTC](https://forums.kodeco.com/t/possible-to-build-a-gui-using-swift-package-manager-as-the-build-system/34454 "2017-09-29T21:16:11Z")

</div>

So far I’m having a great time just using Swift Package Manager to build and test swift code using vim and tmux. I’m also familiar with xcode and the build process there, but found getting a macos command line applicatio…

---

## [Programming in Swift - Part 53. Part 6: Classes: Initializers | Ray Wenderlich](https://forums.kodeco.com/t/programming-in-swift-part-53-part-6-classes-initializers-ray-wenderlich/34935)

<div class="topic-metadata">

**Author:** [@summalabs](https://forums.kodeco.com/u/summalabs)\
**Replies:** 3\
**Last updated:** [September 28, 2017, 10:01pm UTC](https://forums.kodeco.com/t/programming-in-swift-part-53-part-6-classes-initializers-ray-wenderlich/34935 "2017-09-28T22:01:26Z")

</div>

I think in part 53 is video from part 54 (Challenge: Initializers)

---

## [How to reset game at game over?](https://forums.kodeco.com/t/how-to-reset-game-at-game-over/34902)

<div class="topic-metadata">

**Author:** [@derekm](https://forums.kodeco.com/u/derekm)\
**Replies:** 1\
**Last updated:** [September 27, 2017, 4:02pm UTC](https://forums.kodeco.com/t/how-to-reset-game-at-game-over/34902 "2017-09-27T16:02:03Z")

</div>

I am wondering how I can reset my code after the player runs out of time in my game. I have the loss conditions I just don’t know how to reset all the variables and tuples, and labels that have been changed as the game …

---

## [Two tables on same view controller not displaying data](https://forums.kodeco.com/t/two-tables-on-same-view-controller-not-displaying-data/34756)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 3\
**Last updated:** [September 25, 2017, 4:05am UTC](https://forums.kodeco.com/t/two-tables-on-same-view-controller-not-displaying-data/34756 "2017-09-25T04:05:45Z")

</div>

I have 2 tableviews on the same view controller. All I am trying to do is get var text to be dispalyed on both of the tableviews right now nothing is being displayed on either of the tableviews. import UIKit v…

---

## [VNDetectTextRectanglesRequest](https://forums.kodeco.com/t/vndetecttextrectanglesrequest/34714)

<div class="topic-metadata">

**Author:** [@rufy](https://forums.kodeco.com/u/rufy)\
**Replies:** 1\
**Last updated:** [September 22, 2017, 3:49am UTC](https://forums.kodeco.com/t/vndetecttextrectanglesrequest/34714 "2017-09-22T03:49:25Z")

</div>

I’m studying Vision and I’ve read this tutorial. I’ve seen that when you use Vision to detect text while use the camera, Vision scans all image of camera. If I would limit this full scansion using a view, how can I do i…

---

## [Enable button when 2 textifleds are filled](https://forums.kodeco.com/t/enable-button-when-2-textifleds-are-filled/34697)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 1\
**Last updated:** [September 21, 2017, 8:25am UTC](https://forums.kodeco.com/t/enable-button-when-2-textifleds-are-filled/34697 "2017-09-21T08:25:04Z")

</div>

I am trying to not enable a button until both textfields are not nil. Thats it. I tried experimenting with viewdidappear but its not working. As soon as both textfields are not nil the button remains isenable = false. …

---

## [OCR with document layout analysis](https://forums.kodeco.com/t/ocr-with-document-layout-analysis/34433)

<div class="topic-metadata">

**Author:** [@lifeiscrazy2323](https://forums.kodeco.com/u/lifeiscrazy2323)\
**Replies:** 2\
**Last updated:** [September 20, 2017, 9:25am UTC](https://forums.kodeco.com/t/ocr-with-document-layout-analysis/34433 "2017-09-20T09:25:19Z")

</div>

Hi, is there any ocr that gives image’s text along with it’s document’s layout in iOS swift

---

## [Use a pickerView on a outlet collection textfield (swift3)](https://forums.kodeco.com/t/use-a-pickerview-on-a-outlet-collection-textfield-swift3/34406)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 4\
**Last updated:** [September 18, 2017, 9:37pm UTC](https://forums.kodeco.com/t/use-a-pickerview-on-a-outlet-collection-textfield-swift3/34406 "2017-09-18T21:37:36Z")

</div>

My code bellow is a uitextfiled that uses a picker view to display a and b. All I want to do is have the is have the same picker view appear for all of the textfields using outlet collection. Textfield is the single text…

---

## [How to bottom of textview via animation](https://forums.kodeco.com/t/how-to-bottom-of-textview-via-animation/34500)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 1\
**Last updated:** [September 18, 2017, 7:12am UTC](https://forums.kodeco.com/t/how-to-bottom-of-textview-via-animation/34500 "2017-09-18T07:12:09Z")

</div>

My code below scrolls to the top of the textview. The command is .zero. What is the command using this same format to go to the end or bottom of the textview. What is the opposite of .zero? self.theTextView.con…

---

## [Struct not keeping tuple in order (swift3)](https://forums.kodeco.com/t/struct-not-keeping-tuple-in-order-swift3/34207)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 5\
**Last updated:** [September 10, 2017, 7:50pm UTC](https://forums.kodeco.com/t/struct-not-keeping-tuple-in-order-swift3/34207 "2017-09-10T19:50:23Z")

</div>

My Code produces a a tuples that is displayed on a label on view controller 1. I tried struct the label from vc1 to vc2 but the order is not being kept. All I want to do is replicate the exact order and the way the tuple…

---

## [Append array int to a string array](https://forums.kodeco.com/t/append-array-int-to-a-string-array/34111)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 1\
**Last updated:** [September 9, 2017, 12:32pm UTC](https://forums.kodeco.com/t/append-array-int-to-a-string-array/34111 "2017-09-09T12:32:11Z")

</div>

Right now I have a string array that displays a string on a individual line. I would like to take a int array and display on the same line. So the entries of the array are pared in order. So yourArray\[1\] = number\[1\], you…

---

## [Print 2 joined arrays in alphabetical order and in descending order](https://forums.kodeco.com/t/print-2-joined-arrays-in-alphabetical-order-and-in-descending-order/34124)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 1\
**Last updated:** [September 7, 2017, 3:27pm UTC](https://forums.kodeco.com/t/print-2-joined-arrays-in-alphabetical-order-and-in-descending-order/34124 "2017-09-07T15:27:16Z")

</div>

Right now my code prints its string array in alphabetical order. What I would like to do is is organize the array in a way like \[a,1\],\[a,2\],\[b,4). Alphabetical order then in the int descending order. Right now you can se…

---

## [Print array in struct in alphabetical order and in descending order (swift3)](https://forums.kodeco.com/t/print-array-in-struct-in-alphabetical-order-and-in-descending-order-swift3/33986)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 1\
**Last updated:** [September 6, 2017, 4:36pm UTC](https://forums.kodeco.com/t/print-array-in-struct-in-alphabetical-order-and-in-descending-order-swift3/33986 "2017-09-06T16:36:13Z")

</div>

I would like my struct to print its entries by alphabetical order first then arrange the data from descending order way. So the final result should be “lukes 9”, “lukes 4”, “smiths 4” struct MyData { var co…

---

## [Sorting array by alphabetical order not working (swift3)](https://forums.kodeco.com/t/sorting-array-by-alphabetical-order-not-working-swift3/34037)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 3\
**Last updated:** [September 6, 2017, 3:32pm UTC](https://forums.kodeco.com/t/sorting-array-by-alphabetical-order-not-working-swift3/34037 "2017-09-06T15:32:03Z")

</div>

My code adds a entry to the array but I don’t know how to sort in a alphabetical order. I just want to be able to sort whatever is in yourArray in alphabetical order. import UIKit var yourArray = \[String\]() class V…

---

## [Initializer is not appending data](https://forums.kodeco.com/t/initializer-is-not-appending-data/34004)

<div class="topic-metadata">

**Author:** [@timswift](https://forums.kodeco.com/u/timswift)\
**Replies:** 3\
**Last updated:** [September 4, 2017, 2:40pm UTC](https://forums.kodeco.com/t/initializer-is-not-appending-data/34004 "2017-09-04T14:40:47Z")

</div>

I am trying to append whatever is in both textfields to the MyData set. However the data is not be appended into MyData. let sortedArray = MyData.init(company: textA.text!, scorej: Int(textB.text!)!) is being unuse…

---

## [IOS User Location Error "(os/kern) invalid capability (0x14)"](https://forums.kodeco.com/t/ios-user-location-error-os-kern-invalid-capability-0x14/33865)

<div class="topic-metadata">

**Author:** [@boooll](https://forums.kodeco.com/u/boooll)\
**Replies:** 3\
**Last updated:** [September 3, 2017, 4:13pm UTC](https://forums.kodeco.com/t/ios-user-location-error-os-kern-invalid-capability-0x14/33865 "2017-09-03T16:13:38Z")

</div>

for some reason my app launches, the dialog box to request location authorisation appears but it disappears on its own and I am presented with User Location\[47489:8243958\] \[Common\] \_BSMachError: port 5f07; (os/kern) inva…

[Previous page](https://forums.kodeco.com/c/general/swift/15.md?page=24)

[Next page](https://forums.kodeco.com/c/general/swift/15.md?page=26)
