iOS Development is easy with XCode, Swift3, UITableView, cocatouch, let's build iPhone, iPad and Macbook Applications.

Select text in UIAlertController's text field

I need the text of the text field to be selected right after the UIAlertController is presented. However, the way I select text in a standard UITextField doesn’t work here. This is what I tried, but I can’t seem to get it work. let ac = UIAlertController(title: “Rename”, message: nil, preferredStyle: .Alert) ac.addTextFieldWithConfigurationHandler({ [] (textField: […]

Create a new window with NSWindow

I’d like to create a new window programmatically. I have the following code, and it builds, but my window doesn’t show up. The only way I can make it visible is by adding it as a child window to the default ‘window’. How can I make ‘win’ be an independent window? @IBOutlet var window: NSWindow […]

Fast Enumeration through UICollectionView Cells – Swift

I am trying to fast enumerate through all of my collection view cells, however this implementation below is giving me a warning. for cell in self.collectionView?.visibleCells() as [UICollectionViewCell] { // Do Stuff } Error below appears on first line: Operand of postfix ‘?’ should have optional type; type is ‘(UICollectionView, cellForItemAtIndexPath: NSIndexPath) -> UICollectionViewCell’ I’ve […]

swift – sort an array of objects by their optional boolean property without force unwrapping

I can sort this array of store objects by their ‘flagship’ boolean property, but how can I safely unwrap the ‘flagship’ property first? let flagshipStores = self.stores.sort { $0.flagship! && !$1.flagship! }

Is it possible to animate UILabel's textcolor change?

This question already has an answer here: How to animate the textColor property of an UILabel? 8 answers

Swift UIScrollView not scrolling but responding to setContentOffset and Delegate responds

Getting a really bizarre incident with a UIScrollView here which just refuses to scroll. I set it up in my StoryBoard and set the contentSize correctly in my ViewDidLoad. I double checked to ensure that it was Scrollable etc, yet it’s just not working. I set scrollView.setContentOffset() and it scrolls fine with a lovely animation […]

How can I generate an array of floats from an audio file in Swift

I would like to load mp3 and wav audio files as arrays of floats or doubles, similar to the function in scipy. I can do this with microphone data or playing audio by writing the audio stream to a buffer. However, I’m not sure how to load all of an audio file’s data at […]

Subclassing SpriteKit classes in Swift

I’m very new to iOS development, but I’ve been playing around with the SpriteKit template app to learn how things work and try to boot up on Swift while I’m at it. One thing I’m having trouble with is how to work with SpriteKit subclasses. I’m in the GameScene.swift file and I’m trying to extract […]

App is freezing in 'peek and pop' implementation in iPhone 6s

I have implemented peek and pop in my app and it works perfectly. But on continuously trying it for 7-8 times, the app freezes on peek view. The only option I have is to kill the app and re-run. Please let me know the reason for the freeze. I have used the following code for […]

Making an asynchronous call prior to a segue to the next view controller (Swift)

I have a bunch of view controllers (embedded navigation controller), and I need to make some async calls before I segue to the next screen. The problem is that I need to make this call at the time I click the button mapped to the segue, but since the async call hasn’t returned yet, the […]