Do capture lists of inner closures need to redeclare `self` as `weak` or `unowned`?

The [weak self] in anotherFunctionWithTrailingClosure is not needed. You can empirically test this: class Experiment { func someFunctionWithTrailingClosure(closure: @escaping () -> Void) { print(“starting”, #function) DispatchQueue.main.asyncAfter(deadline: .now() + 1) { closure() print(“finishing”, #function) } } func anotherFunctionWithTrailingClosure(closure: @escaping () -> Void) { print(“starting”, #function) DispatchQueue.main.asyncAfter(deadline: .now() + 1) { closure() print(“finishing”, #function) } } func … Read more

Xcode ARC (automatic reference counting), “release is unavailable”

The two options given by NJones are valid and effective ways of dealing with ARC incompatibility. However, you do have a third option. Disabling ARC for specific files. Giving the flags -fno-objc-arc to your non ARC compatible compile sources affectively marks them as such upon compilation. You can find your compile sources under Targets → … Read more

SFHFKeychainUtils. iOS keychain. ARC compatible

here is the ARC compatible SFHFKeychainUtils, SFHFKeychainUtils.h // // SFHFKeychainUtils.h // // Created by Buzz Andersen on 10/20/08. // Based partly on code by Jonathan Wight, Jon Crosby, and Mike Malone. // Copyright 2008 Sci-Fi Hi-Fi. All rights reserved. // // Permission is hereby granted, free of charge, to any person // obtaining a copy … Read more

Why do weak NSString properties not get released in iOS?

NSString uses all sorts of internal trickery to reuse objects and avoid unnecessary allocations and copies. It can do this because NSString instances are immutable. In this case there is probably a shared instance to represent an empty string which is being returned by [[NSString alloc] init], and this shared instance will be retained somewhere … Read more