Swift 2 Error using mutating function in Protocol extension “Cannot use mutating member on immutable value: ‘self’ is immutable

The problem is that, in the protocol you mark the function as mutating, which you need to do if you want to use the protocol on a struct. However, the self that is passed to testFunc is immutable (it’s a reference to a instance of the class) and that is tripping up the compiler. This … Read more

NSInternalInconsistencyException: ‘Invalid parameter not satisfying: !stayUp || CLClientIsBackgroundable(internal->fClient)’

I’ve managed to solve this by doing these two things: added UIBackgroundModes ‘location’ to Info.plist added NSLocationAlwaysUsageDescription to Info.plist As of iOS 11, keys are named: NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription

OSStatus error code -34018

After some research, I found this: http://opensource.apple.com/source/Security/Security-55471/sec/Security/SecBasePriv.h So -34018 is errSecMissingEntitlement and the comment says Internal error when a required entitlement isn’t present. Do you experience this error while running your unit tests? If so, this might help: https://stackoverflow.com/a/22305193/171933 This issue on github says that it only seems to happen while debugging from Xcode: https://github.com/soffes/sskeychain/issues/97 … Read more

Detect if app is running in Slide Over or Split View mode in iOS 9

Just check if your window occupies the whole screen: BOOL isRunningInFullScreen = CGRectEqualToRect([UIApplication sharedApplication].delegate.window.frame, [UIApplication sharedApplication].delegate.window.screen.bounds); If this is false, then you’re running in a split view or a slide over. Here is the code snipped which will automatically maintain this flag irrespective of rotation -(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection { // simply create a property of ‘BOOL’ … Read more

iOS 9 UITableView separators insets (significant left margin)

Okay, I have found out the solution. The only thing required for that is to set on the presenting instance of UITableView that flag cellLayoutMarginsFollowReadableWidth myTableView.cellLayoutMarginsFollowReadableWidth = NO; I wanted to find some reference in the documentation but it looks like it is not ready yet, only mentioned on diff page. As the flag was … Read more

sendAsynchronousRequest was deprecated in iOS 9, How to alter code to fix

Use NSURLSession instead like below, For Objective-C NSURLSession *session = [NSURLSession sharedSession]; [[session dataTaskWithURL:[NSURL URLWithString:”YOUR URL”] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { // handle response }] resume]; For Swift, var request = NSMutableURLRequest(URL: NSURL(string: “YOUR URL”)!) var session = NSURLSession.sharedSession() request.HTTPMethod = “POST” var params = [“username”:”username”, “password”:”password”] as Dictionary<String, String> request.HTTPBody = try? … Read more