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 to avoid forcing a second component one day?

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

Tableview cell subtitles

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

How can I store my data locally using iOS + Swift?

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

How can I detect dual support on UITabBarItem?

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

Asynchronous RxSwift task

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

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

CoreData - Advantages of the NSManagedObject subclass

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

Additional X offset on a horizontally centered element

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

Can you add Target to UIButton in the NSObject class?

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

How to use asynchronous methods (JSON Restful services) in iOS?

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

Code C in Swift Project

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

Triggering the locked notification screen

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

How to access CLLocationManager from Swift?

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

Collection view recycling images while scrolling in swift 2

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

remember methods with closure?

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

ITunes Sandbox account credentials are requested continuously

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

Search string to repeat instances of a word

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

In Swift, why GCD does not work with analyze?

I have already asked this on In Swift, how to stop all the process until datas retrieved from in UICOLLECTIONVIEW. I couldn't retrieve the datas from before next function get executed. I don't know how to access asynchronous threa

When should I access properties with myself in swift?

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

Swift Core Motion closing problem

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

Encapsulation of data in Swift

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