Mac Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsMac Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 5th, 2007, 09:54 AM
wilh wilh is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 wilh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 32 sec
Reputation Power: 0
Trouble invoking method on object returned from NSEnumerator

Hey all,

I'm relatively new to Obj-C, so please bear with me. What I have is a problem where my program crashes when I attempt to invoke a method on an object, but only after it comes out of an NSEnumeration.

The problem occurs when I attempt to invoke [worldLoc x] in the code below. When I invoke this on the object before it goes into the array, it works fine, but after it crashes and brings up the debugger with the stack trace shown after the code below.

Any ideas would be appreciated,

Wil

Code:
- (void)drawRect: (NSRect) drawRect
{
	NSEnumerator *e = [world entityEnumerator];
	WorldEntity *entity;
	int radius = 2;
	float minX = -10.0f;
	float maxX = 10.0f;
	float minY = -10.0f;
	float maxY = 10.0f;
	
	NSPoint location;
	NSRect rect;
	
	while (entity = [e nextObject])
	{
		Vector2D *worldLoc = [entity location];
		
		NSRect bounds = [self bounds];
		
		float pctX = ([worldLoc x] - minX) / (maxX - minX);
		if (pctX >= 0.0 && pctX <= 100.0)
		{
			float pctY = ([worldLoc y] - minY) / (maxY - minY);
			if (pctY >= 0.0 && pctY <= 100.0)
			{
				location.x = bounds.size.width * pctX;
				location.y = bounds.size.height * (1 - pctY);
				
				[self circleRectAt: location withRadius: radius rect: &rect];
				
				[[NSBezierPath bezierPathWithOvalInRect: rect] fill];
			}
		}		
	}
}


Code:
objc_msgSend_fpret
??
-[NSView _drawRect:clip:]
.
.
.


I believe the ?? is my drawRect method. When I run it through the debugger, it crashes when I try to step into [worldLoc x].

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsMac Help > Trouble invoking method on object returned from NSEnumerator


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway