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

How to write a better data access layer with Realm

I’ve been using Realm in a few small projects and I quite like it. I’m hoping to move on to using it in bigger projects and I’m looking for better structure my data access layer. I came across this similar question and tried to build up on the information I found there. The approach discussed […]

Regular expression to get URL in string swift with Capitalized symbols

I try to get URLs in text. So, before, I used such an expression: let re = NSRegularExpression(pattern: “https?:\\/.*”, options: nil, error: nil)! But I had a problem when a user input URLs with Capitalized symbols (like Http://, it doesn’t match it). I tried: let re = NSRegularExpression(pattern: “(h|H)(t|T)(t|T)(p|P)s?:\\/.*”, options: nil, error: nil)! But nothing […]

Custom View – self.frame is not correct?

So I have a custom UIView class class MessageBox: UIView { override init(frame: CGRect) { super.init(frame: frame) createSubViews() } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) createSubViews() } func createSubViews() { let testView = UIView(frame: self.frame) testView.backgroundColor = UIColor.brown self.addSubview(testView) } } I added a UIView inside the storyboard and gave it some constraints: 100 […]

Swift: IBoutlets are nil in Custom Cell

I can’t figure out why this custom cell is not being output. I have a custom cell set up in a storyboard (no nib). I have a text field and 2 labels which are nil when I try to access them in the custom cell class. I’m almost sure I have everything hooked up correctly, […]

How to simply delete old core data and rebuilt the new one?

I tried to migrate coreData to new version, I’m following this step: Add a new Model Version (Select name.xcdatamodeld then Editor->Add model Version) before making any changes, if you have an app already submitted to App Store which is using the earlier model version. Then, Add a new file from Core Data Tab, as Mapping […]

How to Set requestSerializer in Alamofire

I am currently working on a project in swift. I used Alamofire for REST API but to make it work i need to pass a parameter in requestSerializer In AFNETWORKING AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; manager.requestSerializer = [AFJSONRequestSerializer serializer]; But i can’t find anything for Alamofire. I’m new to swift please help me out.

Accessing IBOutlet from another class

I am calling a class function from my ViewController class like this: Buttons.set_cornerRadius(10) I have another .swift file where I have the function declared: class Buttons { class func set_cornerRadius(radius: CGFloat) { ViewController().someButton.layer.cornerRadius = radius } } When I’m trying to run this it throws the error: “Unexpectedly found nil while unwrapping an optional Value”. […]

Handler of addUIInterruptionMonitor is not called for Alert related to Photos

private func acceptPermissionAlert() { _ = addUIInterruptionMonitor(withDescription: “”) { alert -> Bool in if alert.buttons[“Don’t Allow”].exists { //doesnt get here second time alert.buttons.element(boundBy: 1).tapWhenExists() return true } return false } } and this doesnt work for: In the beginning of the app, it works perfect while acepting permission for notifications, but here… doesnt work. Do […]

Swift 3: Safe way to decode values with NSCoder?

Before Swift 3, you decode boolean values with NSCoder like this: if let value = aDecoder.decodeObjectForKey(TestKey) as? Bool { test = value } The suggested approach in Swift 3 is to use this instead: aDecoder.decodeBool(forKey: TestKey) But the class reference for decodeBool doesn’t explain how to handle the situation if the value you’re decoding isn’t […]

Detecting double and single tap on UITableViewCell to perform two action

I have a PFQueryTableViewController in which I am trying to learn some tableView interactions. What I currently have: The tableView cell increases its height on a tap didSelectRowAtIndexPath or I can basically segue cell related data to next viewController using performSegueWithIdentifier together with prepareForSegue using a single tap. In the below code, if I comment […]