質問

When I open a specific Storyboard scene, my app crashes with the error: "incorrect checksum for freed object - object was probably modified after being freed". I've also got some "EXC_BAD_ACCESS" crashes going on, it's usually one or the other. I couldn't find the troubled pointer, so I tested it out with NSZombieEnabled. That lead me to get this message on the crash: *** -[NSContentSizeLayoutConstraint secondItem]: message sent to deallocated instance 0x1e0a5220

Now, I searched the project for [NSContentSizeLayoutConstraint secondItem], and even just NSContentSizeLayoutConstraint and secondItem individually. It exists nowhere in the project. I'm still very new to Objective-C, and have no idea what to do next. Also, it will run just fine like 1 out of 5 times on the device and simulator. This also happened with: -[NSAttributeDictionary release]:, which is no where in my project either. Also, *** -[PitchDetector addSamples:inNumberFrames:]:. They keep changing, and I can't find these anywhere in my project. And it runs just fine sometimes, usually on the simulator, which makes it really frustrating since the error keeps changing on the device when it crashes.

To switch views in the storyboard, I'm using this code. This is in the viewDidLoad on the main screen: x1ViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"x1ViewController"];

And when the button is pushed to load it: - (IBAction)button4:(id)sender { [self presentViewController:x1ViewController animated:YES completion:nil]; }

I've set up all the other page transitions the exact same way and they all switch over just fine. This is the only troubled one.

Here is the stack trace: enter image description here

And here is a weird thing I found during an analysis that I'm unsure of how to fix: enter image description here

Update: I'm also occasionally getting the message "Error: 1768843636" in the console once the page loads. Very strange.

役に立ちましたか?

解決

To switch views in the storyboard, I'm using this code. This is in the viewDidLoad on the main screen:

x1ViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] 
                        instantiateViewControllerWithIdentifier:@"x1ViewController"];

Well, there's your problem. viewDidLoad is way too soon. You aren't even in the interface yet and already you are trying to move to the next state of the interface. Moreover, you are running the risk of trying to present the same view controller instance on different occasions.

Move that code to your button-press code. You don't need this view controller instantiated until the moment comes when you present it. Use a new view controller instance each time you present.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top