Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-08-2010, 03:51 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 6
ClarityGames is on a distinguished road
Default unrecognized selector problem

Hi,

I'm seeing a weird random error happening in my code. The 'unrecognized selector' error is being fired, but when I try to look for the code that's causing the error I can't find it.

For example, I get the error

-[Levels hide]: unrecognized selector sent to instance 0x81c600'

but there is no hide method in my class Levels and, more importantly, there is nowhere in code where I'm trying to call the hide method in Levels. When I debug the error using gdb the line actually calls an instance of [Sprite hide]; It's almost as if a pointer to an instance of Sprite is being overwritten by a pointer to Levels but again there's nothing in code which would cause this.

Is there anything which would cause this apparent corruption of my object pointers at runtime? I'm doing nothing fancy with pointers and it's not in any specific part of code that I can post, if I comment out where the error is happening on one run it'll happen somewhere else the next time I run. But if I run the same code twice it'll happen reliably in the same place.

Aargh!
ClarityGames is offline   Reply With Quote
Old 06-12-2010, 05:01 PM   #2 (permalink)
Eager to Learn Member
iPhone Dev SDK Supporter
 
mkenney's Avatar
 
Join Date: Sep 2009
Posts: 76
mkenney is on a distinguished road
Default

Quote:
Originally Posted by ClarityGames View Post
Hi,

I'm seeing a weird random error happening in my code. The 'unrecognized selector' error is being fired, but when I try to look for the code that's causing the error I can't find it.

For example, I get the error

-[Levels hide]: unrecognized selector sent to instance 0x81c600'

but there is no hide method in my class Levels and, more importantly, there is nowhere in code where I'm trying to call the hide method in Levels. When I debug the error using gdb the line actually calls an instance of [Sprite hide]; It's almost as if a pointer to an instance of Sprite is being overwritten by a pointer to Levels but again there's nothing in code which would cause this.

Is there anything which would cause this apparent corruption of my object pointers at runtime? I'm doing nothing fancy with pointers and it's not in any specific part of code that I can post, if I comment out where the error is happening on one run it'll happen somewhere else the next time I run. But if I run the same code twice it'll happen reliably in the same place.

Aargh!
Does Level inherit from Sprite or Sprite inherit from Level? Shooting in the dark...
mkenney is offline   Reply With Quote
Old 06-12-2010, 10:49 PM   #3 (permalink)
Registered Member
iPhone Dev SDK Supporter
 
smasher's Avatar
 
Join Date: Jul 2008
Location: San Mateo, CA (San Fran)
Posts: 3,858
smasher will become famous soon enough
Default

Quote:
Originally Posted by ClarityGames View Post

-[Levels hide]: unrecognized selector sent to instance 0x81c600'

but there is no hide method in my class Levels and, more importantly, there is nowhere in code where I'm trying to call the hide method in Levels. When I debug the error using gdb the line actually calls an instance of [Sprite hide];
That's a classic symptom of an object that got over-released. You had a pointer to a Sprite, but you released it too many times (or it was autoreleased and you didn't retain it) and it was deallocated. That memory location was reused for the "Levels" object.

Take a look at the life cycle of your Sprite object, and figure out why it's getting released.
__________________

Free Games!
smasher is offline   Reply With Quote
Old 06-22-2010, 02:21 PM   #4 (permalink)
Registered Member
 
Join Date: Feb 2010
Posts: 6
ClarityGames is on a distinguished road
Default Problem solved

Hi Smasher!

You were right, it was an object that I was releasing twice. Problem solved.

Smashing solution, Smasher!
ClarityGames is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 403
11 members and 392 guests
7twenty7, ChrisYates, djohnson, Duncan C, gmarro, hussain1982, Kirkout, Retouchable, SLIC, walex, xzoonxoom
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,921
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:05 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0