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
I'm using this code to create a document for a document base application for macOS, which hase as name the seconds elapsed since the Date() referencing date. func saveDocumentInApplicationSupport() { do { // create a directory in Application Support
My tableview cell subtitles aren't showing when I use this: func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { var cell:UITableViewCell? if tableView.tag == 1 { guard let latestCell = tableView.dequeueReu
For an iOS app in Swift, I am using programmatic constraints and would like to add a CAGradientLayer() to a UIView(). Below is my code which doesn't work. import UIKit class ViewController: UIViewController { let animationView: UIView = { let view =
This question already has an answer here: iOS offline data storage tutorial 2 answers I am new for Swift iOS development. I want to store my data (name, image_path) locally while my app is not able to upload it (no internet connection etc). I have st
I'm relying on an encrypted realm to store certain data in an app written in Swift. Sometimes I face a situation where I delete a given realm and create a new one to ensure that no data will persist between certain states. I keep track of encryption
I've tried adding a gesture recogniser, not realising that it isn't possible with a UITabBarItem, here is what I did: Any other suggestions?I don't think this will have a simple solution, as double tapping a tab bar item is not expected behavior. Eve
I want to start a login task by a login button tapped, after this finished, fetch user order list, shipping address, wish list, other info. startTask is a button, user tap it, i will start these tasks, but now if the login task failure, user tap star
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
I am trying to insert into CoreData without creating a subclass of NSManagedObject. but my app crashes with NSManagedObject setValue:forUndefinedKey "name" in Category. let managedObjectContext = (UIApplication.sharedApplication().delegate as! A
I stripped down my code so that its easy to understand. Say you have a controller and you want to add a simple scroller using pure auto layout. You can invoke my function tool (provided below) as follows: // Create scroll view let strip = addStripCat
I have a SubView inside another View that has other elements inside it. I horizontally centered the middle element of SubView to SubView, but I need to give it an extra horizontal offset. Is there a way to be able to use both Horizontal Center and gi
I'm interested in uploading a video to youtube along with title, description, and keywords. The code below uploads a video to youtube without any properties: func postVideoToYouTube(token: String, callback: Bool -> Void){ let headers = ["Authoriza
How do you addTarget to a UIButton in an NSObject class? Or will that class not work? class Support: NSObject { func helpButton(viewController: ProfileVC) { let helpButton = viewController.helpButton helpButton.frame.size = CGSizeMake(35.0, 35.0) hel
I have an iOS application that sync data from a JSON restful web service. This method is called from an external class (not UI controller). This class has a sync method and It sends and retrieves data without any problem. My problem is how do I pause
I have a C program, that I would like to print its output from swift, and when it scans I can give it input through Swift. Is such thing possible? I tried this with a simple function, and it worked, but how can someone do so with many different funct
In my Swift iOS app, I am able to capture that a notification was received, when either the app is running, or when the user gets a notification and clicks on the notification after receiving it. But if the user received the notification when outside
Get User's Current Location / Coordinates has something that appears to be what I want: you should do those steps: add CoreLocation.framework to BuildPhases -> Link Binary With Libraries import CoreLocation to your class - probably ViewController.swi
I'm simply desperate, searched for 6 hours now and can't seem to find an answer. I have a collection view with images loaded from a remote server and while scrolling the cells are being refreshed with previous images for a few seconds before settling
This is a very specific question i got from treehouse part one: We're writing an app to fetch the most recent blog posts from the Treehouse blog. This requires making a network request using asynchronous methods that execute in the background. For th
I am trying to implement IAP in my application but now it asks for sandbox account continuously. I tried removing that account from sandbox testers, but result is same.I removed all IAP related codes,but result is still same.I downloaded my app from
The following code was working ok on XCode 6/Swift 1, but gives me an error on XCode 7/Swift 2 Alamofire.request(.POST, "\(self.REQ_URL)", parameters: parameters).validate(contentType: ["application/json"]).responseJSON(options: [], co
This question already has an answer here: Table view didSelectRowAtIndexPath, only works after selecting second click 1 answer So here's the thing: I implemented a UITableViewController with a custom cell.. Then i replaced the automatic segue cell to
It seems as a bug in Social framework, it won't set the initial text for Facebook service type. This is my implementation using Swift: let view = SLComposeViewController(forServiceType: SLServiceTypeFacebook) if view.setInitialText("Some text")
I'm trying to query images from Parse and I continue to run into fatal error: unexpectedly found nil while unwrapping optional value. I'm not sure if this has to do with the recent update to Swift and Xcode, so maybe it's on the Parse end or it could
I have a string, and I want to find the locations of every user chosen word inside that string. For instance, if the user chooses "my", I want to find every time "my" is found in the string. Currently I am using: var range = stringCont
I have already asked this on In Swift, how to stop all the process until datas retrieved from parse.com in UICOLLECTIONVIEW. I couldn't retrieve the datas from parse.com before next function get executed. I don't know how to access asynchronous threa
In a simple example like this, I can omit self for referencing backgroundLayer because it's unambiguous which backgroundLayer the backgroundColor is set on. class SpecialView: UIView { let backgroundLayer = CAShapeLayer() init() { backgroundLayer.bac
I'm trying to convert an old game application built in obj-c to the new swift code. i'm having some issues understanding swift closures and how to use them for example in the"startAccelerometerUpdatesToQueue" method. i have initialized the motio
I've read the entire Swift book, and watched all the WWDC videos (all of which I heartily recommend). One thing I'm worried about is data encapsulation. Consider the following (entirely contrived) example: class Stack<T> { var items : T[] = [] func