Pointers in Swift

I'm trying to understand the use of pointers in Swift, in particular: Unsafe[Mutable]Pointer and UnsafeRaw[Mutable]Pointer. I have several questions on the subject. Is UnsafePointer <T> equal to const T * Pointer in ? and UnsafeMutablePointer...
more »

2017-02-22 15:02 (1) Answers

Get next value on a map?

I'm trying to compare element to next element in a collection. For example : let array: [(Double, String)]= [(2.3, "ok"), (1.4, "ok"), (5.1, "notOk")] I need a returned array who wil...
more »

2017-02-22 14:02 (4) Answers

Set cellDelegate using generic

Hi guys how are you? Hope you guys are fine. I need a little help and i thank you in advance. I have a custom delegate in my custom cell, like this: protocol customTableViewCellDelegate: NSObjectProtocol { func buttonPressed(customCell: custom...
more »

2017-02-22 11:02 (1) Answers

View on Top of UITabBar

Similar to what the Spotify or Apple Music app does when a song is playing, it places a custom view on top of the UITabBar: Solutions I've tried: UITabBarController in a ViewController with a max-sized Container View, and the custom view on top o...
more »

2017-02-22 07:02 (2) Answers

Only else-block of "if let"?

In a cellForRowAtIndexPath I have: if let imageView = cell.viewWithTag(SOME_TAG) as? UIImageView { // Nothing to do here. } else { // Add image view to cell. } but I only need the else block. Is there a way to invert a if let xyz =? (I kn...
more »

2017-02-21 15:02 (4) Answers

Create Generic Realm repository in Swift

I have been struggling with solving a problem which I am pretty sure leads me to adopt the Type-Erasure technique but I am not 100% sure. I have tried several different times and have felt close but ultimately have failed. I will try to simplify my p...
more »

2017-02-21 14:02 (1) Answers

Avoiding repeating code in swift

In following code, based on the string comparison I am deciding on which VC will be shown. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { dataObj = frc.object(at: indexPath) as! Data_Object var pvc: UIViewCo...
more »

2017-02-21 10:02 (4) Answers

How to use Core data in widget today extension?

I'd like to use core data in today extension. I tried some ways down below. create app group and target to both app and today extension! create CoreDataStack class following this link full code is here : final class CoreDataStack { static let ...
more »

2017-02-21 08:02 (1) Answers

Understanding optional global variables in swift

I'm working through a book on Swift and I understand the idea of scope in functions so what I'd like to understand next is why we set global variables using optional types in classes. Honestly it looks like we don't set these variables per say but j...
more »

2017-02-21 05:02 (3) Answers

Referring to own type in Swift?

When in a class, how to refer to the class itself when declaring closure parameters? In the example below, what type to place in place of Self so that when constructing Foo, the closure parameter also becomes Foo and similarly for AnotherFoo? class...
more »

2017-02-21 00:02 (1) Answers

Parse migration Error to mLabs and Heroku

I migrated my parse db to Mlabs at least a year ago. I have been working on the app since and parse dashboard said I had migrated successfully. Mlab and Parse were both receiving updates to their databases. However in the last week or two the app no...
more »

2017-02-20 20:02 (2) Answers