Pagination Swift 3 Array?

Hello I'm trying to do pagination for array of contacts, some how i the code crashed on paged 2 here is my code : // Initialize let limit : Int = 10 var page : Int = self.defaults.integer(forKey: "ConPage") == 0 ? 1 : self.defaults.integer(forKe

Segmented control does not work as expected on segment 0

I have a segmented control that alters 5 images on one of my View Controllers (see image below) but I want Segment 0 to be selected straight away when someone goes into the Casting Tab. At present it only gets selected when i go onto either Segment 1

Sort Dictionary Table in Swift

I am getting an array from response as below items=[{ "displayName": "Adam Codo", "postedTime": "2011-04-04T21:31:20.000Z", "message" : "Hello Test Message" }, { "displayName": "Le

How can I capture events from a switch in a UITableViewCell?

In Xcode 8.3.2 Swift 3.1, I have a UITableView where each row contains a label and a switch. I can manage the switches as a group (process the array), but what I would really like is to have a ValueChanged event fire in the parent UIViewController wh

How to delete all UserDefaults data? - Fast

This question already has an answer here: Delete all keys from a NSUserDefaults dictionary iOS 14 answers I have this code to remove all UserDefaults data from the app: let domain = Bundle.main.bundleIdentifier! UserDefaults.standard.removePersistent

Remove some lines from the chain

I have a string: first line second line first line first line second line first line How can I remove secondlines from this string? Secondlines are always different, firsts too. Only division between them is \n\n. import Foundation let string = "firs

Set the date of tomorrow from the swift custom date

i have an app and user can select date from that. How to Set Tomorrow Date from selected date. For example if user select date 24 it print 25 and if user select date 31 it print 1. Right now i'm using current date to set tomorrow's date let dates = D

indexPath.row does not receive data from the table

I've created a PFQuery to get some strings from my parse server and the put this in a couple of arrays var packsAvailable = [""] var packsImage = [""] var packsDescription = [""] If I print the value of the array in the for l

NSFastEnumerationIteration.member Swift 3

I have some difficult to convert my Swift 2.2 app to Swift 3.0. I have some errors and I don't find the solution yet. Currently, my worst problem is with NSFastEnumerationIteration, I try to get records from JSON but with this error I can't. This is

iOS Swift Custom Cell NavigationController

I have CollectionView in TableView. everything ok but. when I want to navigate my cell to another viewController I got error func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath){ let storyboard = UISt

NSTimer is not disabling even after trying the main solution

I have set a NSTimer and have tried invalidating it but the timer still triggers the selector. I have already tried what many threads have suggested and set and invalidated the timer on the main thread.Solved the issue by invalidating the timer befor

how to maintain the spacing between the uicollectionview cell

In my app I am using using UICollectionView. I want to set fix space between UICollectionViewCell. so how can I do this? here is my code: func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minim

Possible reasons for memory leaks in iOS?

I'm researching possible memory leak traps in iOS and I keep coming across strong reference cycles. This has become clear and the only thing mentioned that I can find regarding memory leaks, even in Apple's documentation. What are some other causes f

Call a function in swift correctly

I'm working on a iPhone App and have a little question. I have a function and want to call this function in my viewDidLoad-function. I have tried this way but I get an error when I want to call the dropPin-function. override func viewDidLoad() { supe

performSegueWithIdentifier of an NSView subclass?

I have a document window that contains a number of NSView subclasses, switched between using a tab control. Each of the subclasses, and the window's ViewController, support different user actions accessed through menu items tied to the First Responde

RESTful mechanism to download video (and properties) to vimeo

The procedure to upload a video to Vimeo starts out very similarly as the one defined for Youtube, but only up to a point. Below I describe the steps that worked, and outline the last video-upload step which does not: The Vimeo-upload dance begins wh

quick to the goal C set image prom facebook

How can I write the code below in Objective C: let strPictureURL: String = (result.objectForKey("picture")?.objectForKey("data")?.objectForKey("url") as? String)! self.ivUserProfileImage.image = UIImage(data: NSData(contentsO

How to delete basic data values ​​in swift 2

for example here is the portion of my code that add values do { let request = NSFetchRequest(entityName: "users") let results = try context.executeFetchRequest(request) if results.count > 0 { for item in results as! [NSManagedObject] { let fN

Deinit did not call a UIViewController, but Dealloc is

It seems like the Swift equivalent of dealloc is deinit. However, when you attempt to define the method on a UIViewController, it doesn't behave as you would expect... Setup Create a new Single View project using Xcode 7.0, in either Swift or Objecti

Alpha does not change the barTintColor of UINavigationBar

I want to set the color of UINavigationBar to black with alpha 0.6 to see my interface. But if i use this code: self.navigationController?.navigationBar.barTintColor = UIColor(red: 0/255, green: 0/255, blue: 0/255, alpha: 0.6) self.navigationControll

Location to save the initial data file?

Warning, I'm a designer, stumbling my way around Swift, so apologies ahead of time for my ignorance. The app I'm working on will ship with a JSON data file with all data (so that the app is accessible without connection). When the app runs I check a

NSURLConnection delegate methods not called in generic class

I have a test class that tries to reach to google with a NSURLConnection. If I try to make it generic, the NSURLConnectionDataDelegate methods are never called. class Remote<T: NSObject>: NSObject, NSURLConnectionDelegate, NSURLConnectionDataDelegat

How to unload self.view of UIViewController in Swift

According to View Controller Programming Guide, we can explicitly unload self.view from UIViewController by assigning nil to self.view. But in Swift, view property in UIViewController is declared as var view: UIView It's not UIView! and thus followin

How to create an empty SKSpriteNode in Swift?

How do I create an empty SKSpriteNode in Swift? I need a SKSpriteNode which I can add SKSpriteNode children to. The equivalent of this in Objective-C: SKSpriteNode *textSprite = [SKSpriteNode new]; Let type inference do the work of figuring out the t

EXC_BAD_ACCESS in Swift when adding a SKSpriteNode

I am creating a little game in Swift for OS X to practise but I encountered an error unkonwn to me. It appears when I try to create two new SKSpriteNodes: var battleBegan:Bool = false let beginButton = SKSpriteNode(imageNamed: "button") var back

DocumentType does not match Xcode 6 Beta 5 using Swift

I was building a Document based app for OS X using Swift in Xcode 6 Beta 4 and it worked fine. After upgrading to Xcode 6 Beta 5, however, I get the following error message every time a document window tries to open: The DocumentType type doesn't map

Detect clicks on a button in Swift

How can I detect clicks on the following UIKit element in Swift, in an Xcode 6 playground? let testLabel = UILabel(frame: CGRectMake(0, 0, 120, 40)) testLabel.text = "My Button" The UILabel class is used just to display text on the screen. Sure

Stop / Pause fast application for the period of time

My app uses multiple threads of NSTimer Object. Within the one function (called randomly at random times, not a fixed delay) I want it to pause the whole app, pause the threads for 1 second only. I have the following code: [self performSelector:@sele

Swift and Spritekit will not work on a device running iOS 7.1

I'm getting a really weird warning when I try to run my Swift project on my device, using Xcode 6. The device is running iOS 7.1, and my mac is running Mavericks. I have written a little game in Swift and SpriteKit, and it works in Simulator, but whe