My Favourite Ios Evolution Bugs

There are some things inwards iOS evolution that tin actually choose grip of you lot out the get-go fourth dimension you lot run into them in addition to of late I was inspired to brand a listing every bit in addition to when I scream back them. This way that I volition add together to this post over fourth dimension every bit I recall things. I laid out alongside 2 issues. The get-go is a mutual effect on StackOverflow.

1. NSUserDefaults non storing values

When testing something it is mutual to throw everything inwards viewDidLoad: but the employment inwards the instance of NSUserDefaults is that it stores information asynchronously in addition to thus if you lot endeavor in addition to at nowadays retrieve what you lot accept but stored thus it commonly isn't there. The solution is to delay the retrieval, using for illustration a push that triggers the retrieval after for testing purposes. Or synchronise() the user defaults.

2. UIDocumentInteractionController crashes my app when I endeavor to opened upward a file inwards some other app

When using a UIDocumentInteractionController it is real of import to keep a reference to the controller instance. If released also early on your app tin crash. So this volition crash:
class ViewController: UIViewController {      // called when bar push detail is pressed    @IBAction func shareStuff(sender: AnyObject) {        allow fileURL = NSBundle.mainBundle().URLForResource("MyFile", withExtension: "txt")!        // Instantiate the interaction controller        allow docController = UIDocumentInteractionController(URL: fileURL)        if allow barButton = sender as? UIBarButtonItem {            docController.presentOptionsMenuFromBarButtonItem(barButton, animated: true)        }        else {            print("not a bar button!")        }    } }     
but this wouldn’t:
class ViewController: UIViewController {    // UIDocumentInteractionController instance is a degree belongings    var docController: UIDocumentInteractionController!    // called when bar push detail is pressed    @IBAction func shareStuff(sender: AnyObject) {        allow fileURL = NSBundle.mainBundle().URLForResource("MyFile", withExtension: "txt")!        // Instantiate the interaction controller        docController = UIDocumentInteractionController(URL: fileURL)        if allow barButton = sender as? UIBarButtonItem {            docController.presentOptionsMenuFromBarButtonItem(barButton, animated: true)        }        else {            print("not a bar button!")        }    } } 
The other of import affair to last aware of is that testing UIDocumentInteractionController inwards the Simulator is actually a no-go because get-go in that place is a sparsity of apps that are installed on the Simulator in addition to minute it behaves badly. You must instead essay on a existent device.

3. Auto Layout misbehaving

Aside from the complexities of Auto Layout which has been discussed inwards other posts on this blog, I accept noticed a style to over utilisation layoutIfNeeded() inwards conjunction alongside Auto Layout in addition to if you lot are doing this for constraints where nix but orientation is changing thus you lot mightiness good desire to expect at removing this layout-triggering code.

There are times when layout methods are required, for illustration on the changing in addition to animating of constraints, but at other times Auto Layout lone is to a greater extent than than capable and, to a greater extent than than this, layoutIfNeeded() can campaign issues. (Note: if you lot produce abide by yourself inwards the province of affairs of needing layoutIfNeeded() also investigate the less abrupt, setNeedsLayout(), which waits for the side past times side layout bicycle earlier making changes in addition to this tin conk along things to a greater extent than inwards sync.)

Comments

Popular posts from this blog

Removing The Index.Php File From Url Inward Codeigniter

What Are The Main Components of a Computer System

Delete Daily Doppler E-Mail Spam From An Iphone [Fix]