MrDatabase
MrDatabase

Reputation: 44495

Why is my iPhone app crashing?

When I try to allocate a Texture2D the app just crashes. I've stepped through the code where the crash occurs... all I can tell is "EXC BAD ACCESS". Here is the line in the app delegate that makes it crash:

_textures[myTex] = [[Texture2D alloc] initWithImage: [UIImage imageNamed:@"sometex.png"]];

sometex.png has been added to the resources folder via "add existing files". I've was able to load this png just fine in some sample code... but now when I try to duplicate the functionality of the sample code it just crashes. Any ideas?

Also I can do the following just fine:

_textField = [[UITextField alloc] initWithFrame:CGRectMake(60, 214, 200, 30)];

Upvotes: 0

Views: 695

Answers (2)

Ben Gottlieb
Ben Gottlieb

Reputation: 85542

Is "sometex.png" in your resources? If you right-click on the .app that Xcode creates and select "Show Package Contents", do you see it there? It sounds like it's not being bundled with your app at build time.

Upvotes: 1

MrDatabase
MrDatabase

Reputation: 44495

Looks like the program can't find "sometex.png". When I replace "sometex.png" with the entire path"users/ blah blah /sometex.png" the crash doesn't happen.

Upvotes: 0

Related Questions