Xcode 8 with "Release: Fastest, Smallest [-Os]" have some weird issue and not functional well in some case Xcode 8 with "Release: Fastest, Smallest [-Os]" have some weird issue and not functional well in some case ios ios

Xcode 8 with "Release: Fastest, Smallest [-Os]" have some weird issue and not functional well in some case


Your problem is in this line:

__weak NSString *aStrTitle = [NSString stringWithFormat:@"%@",aDimensionModel.dimension_description];

+[NSString stringWithFormat:] creates a new string with retain count equal to zero. And this is usually okay, since this value is either assigned to a strong variable or passed as a parameter to the method call. In both cases it's retain count gets incremented and the value remains untouched. But you are assigning this new string to the __weak variable! Weak variables don't affect retain count so it remains zero after this line executed. And so the created string gets deleted immediately after creation.

Solution is simple: remove __weak specifier and you'll be good to go.

There is no point in declaring local variables as weak (unless they are captured by the blocks). Also "cleanups" like this one: aStrVCName = nil; have no effect at all.

  • All local variables are automatically released when the method finishes its execution.
  • aStrVCName is weak anyway, so it never affects retain counts of the objects it's pointing to.


I had a similar issue when migrating to xcode 8 and swift 3. Turns out, swift doesn't like the fact I override functions from the base classes in extensions. see Overriding methods in Swift extensions

For some reason, the compiler doesn't complain about it, and to make things worse, the "strange issues" only started to happen in the Fastest, Smallest [-Os] optimization level.

Seems that in the Fastest, Smallest [-Os] optimization level, the compiler will call the function from the base class, and not the function from the extension. In the None [-O0] optimization level, the compiler will call the function from the extension.

for example:

public class BaseController : UIViewController {    override func reloadInterface() {      println("ok")    }}public class NewController : BaseController {    override func viewDidLoad() {      super.viewDidLoad()      reloadInterface()     }}extension NewController {   override func reloadInterface() {      println("extended function")    }}

will print out "extended function" in none optimization level, and will print out "ok" in fastest optimization level...

to make story short, don't override functions in swift extensions