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 Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-27-2011, 09:37 PM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 35
Kenenth is on a distinguished road
Default Why isnt my CGPoint detector working?

In my app, there are objects that go in certain directions on the screen based on variables that are stored into an NSMutableArray. To save memory, once these items go off the screen, I would like to remove them from the array and the view. Here is my code, but it doesnt seem to be working. I have tryed NSLogging or putting in breakpoints to see if it works, but even when the objects go off of the screen, it doesnt do anything. Could someone please tell me what to do to fix it? Thanks in advance.

Code:
for(int control=0;control<[randomObjectArray count];control++){
UIImageView *randomObject = [randomObjectArray objectAtIndex:control];
if(randomObject.center.x==0){
				
	[randomObject removeFromSuperview];
	[randomObjectArray removeObjectAtIndex:control];
	randomObject = nil;
	NSLog(@"Removed randomObject from the Array");
				
}
Kenenth is offline   Reply With Quote
Old 04-27-2011, 09:39 PM   #2 (permalink)
almostfunnydev
iPhone Dev SDK Supporter
 
rocotilos's Avatar
 
Join Date: Oct 2009
Age: 34
Posts: 3,015
rocotilos is on a distinguished road
Default

if(randomObject.center.x==0)

won;t work because a 0 in float might be 0.0001 or -0.0003 etc.
You need to do something like

(x<=0.005)&&(x>=-0.005)
rocotilos is offline   Reply With Quote
Reply

Bookmarks

Tags
cgpoint, detector, nsmutablearray, screen

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: 341
12 members and 329 guests
dansparrow, iOS.Lover, lorrettaui53, MikaelBartlett, Nobbsy, oztemel, pbart, PlutoPrime, samdanielblr, sledzeppelin, thephotographer, Trickphotostudios
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,120
Posts: 402,897
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

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