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

Firebase Value and ChildAdded (further explanation needed)

I’ve read the Firebase documentation over and over and again and just need some clarification. This isn’t regarding my specific code as much as my understanding of Firebase in general. I know that .Value retrieves all the data each time its called and continues to monitor the database for changes. And .ChildAdded looks for changes […]

How to change CIDetector orientation?

So I am trying to make a text detector using CIDetector in swift. When I point my phone at a piece of text, it doesn’t detect it. However, if I turn my phone to the side, it works and detects the text. How can I change it so that it detects text at the correct […]

Swift Stable Sort?

At this time (March 28, 2015): If I want to use a stable sort in swift, I have to use NSArray and sortWithOptions or write my own stable sort in Swift such as an insertion sort? I see in the Apple Swift docs that sorted is not stable. Example of stable sort in NSMutableArray: [array […]

is `addingPercentEncoding` broken in Xcode 9?

in Swift 3.x with Xcode 9 beta 2, using addingPercentEncoding gives unexpected results. CharacterSet.urlPathAllowed always contains “:”, so by definition of addingPercentEncoding, it should never escape it. Yet, using this code: // always true print(CharacterSet.urlPathAllowed.contains(“:”)) let myString = “info:hello world” let escapedString = myString.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed)! print(escapedString) I get those results: cases where I get an […]

CTCallCenter in Swift

I’m trying to use CTCallCenter in Swift, however it always displays error. I suppose it may cause in how to use closure but actually I don’t familiar about it. Does anybody have idea to resolve this issue? Here is my code import CoreTelephony class ViewController: UIViewController{ var callCenter:CTCallCenter = CTCallCenter() override func viewDidLoad() { callCenter.callEventHandler(call:CTCall) […]

Setting Alternate App Icon returns error 3072: “The operation was cancelled” in iOS 10.3

I am trying to set the alternate icons for my app in iOS 10.3, but every time I call the method Xcode returns: Error Domain=NSCocoaErrorDomain Code=3072 “The operation was cancelled.” I am using @KlimczakM’s answer from this post to set the icon (the specifyIcon method called below) but I am using my own method to […]

Creating a pie chart in swift

I’m trying to create a pie chart in swift, and would like to create the code from scratch rather than use a 3rd party extension. I like the idea of it being @IBDesignable, so I started with this: import Foundation import UIKit @IBDesignable class PieChart: UIView { var data: Dictionary<String,Int>? required init(coder aDecoder: NSCoder) { […]

Swift: How to set UIScrollView contentSize height to height of contents?

I have a UIScrollView. Right now I am just setting it to double the height of the screen (frame in this case is just UIScreen.mainScreen().bounds): class VenueDetailView: UIScrollView { required init?(coder aDecoder: NSCoder) { fatalError(“Storyboard makes me sad.”) } override init(frame: CGRect) { super.init(frame: frame) contentSize = CGSize(width: frame.width, height: frame.height*2) <—————- backgroundColor = UIColor.greenColor() […]

updateValue not working for Dictionary

I’m creating a test app using Swift in Xcode, and I’ve run into an annoying issue. I’m writing a simple class that will act as a cache using a Dictionary object. My implementation is below: import Foundation import UIKit class ImageCache { var dict:Dictionary<String,NSData>?; init() { dict = Dictionary<String,NSData>(); } func exists(id:String) -> Bool { […]

Embedded Content Contains Swift Code with Xcode 8 Beta

I am developing a command line macOS application(with Objective-C) which uses other 3rd party Swift libraries. I am retrieving an error says “dyld: Library not loaded: @rpath/libswiftAppKit.dylib“ Previous answers recommend to set “Embedded Content Contains Swift Code” flag to true. However, this flag is missing with Xcode 8 beta. I have tried “ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES“, which i […]