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

Xcode changes location of applications folder on build

I am storing an .mp3 in my iOS apps documents directory and saving the path to Core Data. When I rebuild the app Xcode seems to move the application data to a different directory thus making the stored path invalid. Why is this happening and what are the best practices around saving file paths? I […]

Is it possible to deactivate collisions in physics bodies in spriteKit?

I’m looking at doing the best way to collect items with my hero in my spriteKit game for iOs, and after to try a few ways to do it, my conclusion is the best way would be to have an item with a physic body which can detect collisions but don’t collide with my hero. […]

URL Encode Alamofire GET params with SwiftyJSON

I am trying to have Alamofire send the following parameter in a GET request but it’s sending gibberish: filters={“$and”:[{“name”:{“$bw”:”duke”},”country”:”gb”}]} //www.example.com/example?filters={“$and”:[{“name”:{“$bw”:”duke”},”country”:”gb”}]} //Obviously URL encoded This is my code: let jsonObject = [“$and”:[[“name”:[“$bw”:string], “country”:”gb”]]] let json = JSON(jsonObject) print(json) outputs { “$and” : [ { “name” : { “$bw” : “duke” }, “country” : “gb” } ] […]

How to define a macro globally in Objective-C?

I want to define a macro globally. I want to override NSLocalizedString() throughout my whole project. Is that possible and how do I do it?

This class is not key value coding-compliant (with storyboard)

I’m just getting started in iOS development with Xamarin and seem to have hit a road block. I’m trying to create a custom table cell to display some data. So taking prompts from various online sources (see here for example), I created a .xib file deleted the view that Xamarin automatically created and replaced it […]

iOS subview displayed as a black rectangle if drawRect is overwritten

I have a storyboard which loads loads a custom UIView. Also a sub view is added to the view in the storyboard. It worked fine until I overwrote the drawRect method of the sub view, then I just saw a black rectangle instead of the subview. Here is the code: #import <UIKit/UIKit.h> #import “MySubview.h” @interface […]

UIBezierPath Subclass Initializer

I’m trying to create a subclass of UIBezierPath to add some properties that are useful to me. class MyUIBezierPath : UIBezierPath { var selectedForLazo : Bool! = false override init(){ super.init() } /* Compile Error: Must call a designated initializer of the superclass ‘UIBezierPath’ */ init(rect: CGRect){ super.init(rect: rect) } /* Compile Error: Must call […]

XCTAssertEqual for custom objects in Swift

XCode 6, Beta 5 I have a unit test like this: func testMyObjectsEqual() { //…. XCTAssertEqual(myObject, myOtherObject, “\(myObject) and \(myOtherObject) should be equal”) } XCTAssertEqualObjects is no longer available in Swift since the language makes no distinction between scalars and objects. So we have to use XCTAssertEqual which leads to the following error: “Type MyObject […]

Where to update Autolayout constraints when size changes?

I have several UIViews laid out along the bottom of a containing UIView. I want these views to always be equal width, and always stretch to collectively fill the width of the containing view (like the emoji keyboard buttons at the bottom). The way I’m approaching this is to set equal widths to one of […]

Making stringWithContentsOfURL asynchronous – Is it safe?

I attempted to make -[NSString stringWithContentsOfURL:encoding:error:] asynchronous, by running it a-synchronically from a background thread: __block NSString *result; dispatch_queue_t currentQueue = dispatch_get_current_queue(); void (^doneBlock)(void) = ^{ printf(“done! %s”,[result UTF8String]); }; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL), ^(void) { result = [NSString stringWithContentsOfURL:[NSURL URLWithString:@”http://www.google.com/”] encoding:NSUTF8StringEncoding error:nil]; dispatch_sync(currentQueue, ^{ doneBlock(); }); }); Its working fine, and most importantly, its asynchronous. […]