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 04-03-2010, 05:01 AM   #1 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 3
nosuic is on a distinguished road
Default How to deallocate an EAGLView instance

Hello all,

I create an instance object and want to deallocate it. Since I cannot straightly call its dealloc method, I call its release function but using breakpoint I can see its dealloc function is never called. I checked then the retainCount of my instance and it's 3 ! What should I do then? I tried the silly solutions of calling release more than once by ended with an EXC_BAD_INSTRUCTION. How can I deallocate this instance ??

The object I want deallocated is glView:

glView = [[EAGLView alloc] initWithFrame:CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height)];
[self.view addSubview:glView];
int x = (int)[glView retainCount]; // 3!
[glView release];


Thank you!
nosuic is offline   Reply With Quote
Old 04-03-2010, 04:57 PM   #2 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 3
JustSid is on a distinguished road
Default

Code:
int j = [glView retainCount];
for(int i=0; i<j; i++)
	[glView release];
Or: don't retain the render view.
JustSid is offline   Reply With Quote
Old 04-04-2010, 05:52 AM   #3 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 3
nosuic is on a distinguished road
Default

Quote:
Originally Posted by JustSid View Post
Code:
int j = [glView retainCount];
for(int i=0; i<j; i++)
	[glView release];
Or: don't retain the render view.
Has this ever worked for you? Because for me crashed my application.

Well the solution was that the 2 owners of my object who I didn't know, came from the animation and the view. So I stopped the animation, removed the subview and then released my instance and it worked well.
nosuic is offline   Reply With Quote
Old 04-04-2010, 12:26 PM   #4 (permalink)
Super Moderator
 
Join Date: Oct 2009
Location: San Diego, CA
Posts: 1,586
JasonR is on a distinguished road
Default

Since you've added it as a subView, you need to remove it first, probably with [glView removeFromSuperview]; If you manage to get it to dealloc while it's still a subView, I would imagine that would crash the program.
JasonR is offline   Reply With Quote
Old 04-04-2010, 12:41 PM   #5 (permalink)
Registered Member
 
Join Date: Apr 2010
Posts: 3
nosuic is on a distinguished road
Default

Yes, so that's what I already said I did:
Quote:
Originally Posted by nosuic View Post
So I stopped the animation, removed the subview and then released my instance and it worked well.
nosuic is offline   Reply With Quote
Reply

Bookmarks

Tags
eaglview, opengl es

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: 405
8 members and 397 guests
iOS.Lover, JackReidy, jeroenkeij, Leslie80, Sami Gh, Wikiboo, Yosh_K
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,671
Threads: 94,121
Posts: 402,903
Top Poster: BrianSlick (7,990)
Welcome to our newest member, JackReidy
Powered by vBadvanced CMPS v3.1.0

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