<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>cocos2d for iPhone &#187; Topic: MenuItemImage selector&#039;s target</title>
		<link>http://www.cocos2d-iphone.org/forum/topic/2483</link>
		<description>A fast, easy to use, free, and community supported 2D game engine</description>
		<language>en-US</language>
		<pubDate>Fri, 10 Feb 2012 01:43:22 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.cocos2d-iphone.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.cocos2d-iphone.org/forum/rss/topic/2483" rel="self" type="application/rss+xml" />

		<item>
			<title>tutukun on "MenuItemImage selector&#039;s target"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2483#post-15613</link>
			<pubDate>Fri, 16 Oct 2009 08:45:36 +0000</pubDate>
			<dc:creator>tutukun</dc:creator>
			<guid isPermaLink="false">15613@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>so anyone has any idea?
</p></description>
		</item>
		<item>
			<title>tutukun on "MenuItemImage selector&#039;s target"</title>
			<link>http://www.cocos2d-iphone.org/forum/topic/2483#post-15546</link>
			<pubDate>Thu, 15 Oct 2009 18:02:09 +0000</pubDate>
			<dc:creator>tutukun</dc:creator>
			<guid isPermaLink="false">15546@http://www.cocos2d-iphone.org/forum/</guid>
			<description><p>ok, So here is the situation:<br />
I have a FoodMenu:Menu class since i need to overwrite the touch functions. </p>
<p>'@property(nonatomic, retain) Texture2D* selected;</p>
<p>-(id) init<br />
{<br />
	MenuItemImage* apple = [MenuItemImage itemFromNormalImage:@"food_healthy_apple.png" selectedImage:@"food_healthy_apple.png" target:self selector:@selector(giveapple:)];</p>
<p>	self = [[FoodMenu menuWithItems:apple, nil] retain];<br />
	[self alignItemsInColumns:[NSNumber numberWithUnsignedInt:3],[NSNumber numberWithUnsignedInt:3], nil];</p>
<p>	selected = nil;<br />
	worldItem = nil;<br />
	world = [World sharedWorld];</p>
<p>	return self;<br />
}</p>
<p>-(void) giveapple: (id)sender<br />
{<br />
	if(selected)<br />
		[selected release];<br />
	selected = nil;<br />
	selected = [[TextureMgr sharedTextureMgr] addImage:@"food_healthy_apple.png"];<br />
}</p>
<p>-(BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event<br />
{<br />
	if(self.visible == NO) return NO;<br />
	[super ccTouchBegan:touch withEvent:event];<br />
	if(!selectedItem)<br />
	{<br />
		self.visible = NO;<br />
		return NO;<br />
	}<br />
	//[selectedItem activateWithTarget:self];<br />
	[selectedItem activate];<br />
	return YES;<br />
}'</p>
<p>It seems instead of copy pointer, the invocation create an copy of the actual instance of the target. Ive test it by create a func call activeWithTarget in MenuItem</p>
<p>'-(void) activateWithTarget:(id)target<br />
{<br />
	if(isEnabled)<br />
        [invocation invokeWithTarget:target];<br />
}'</p>
<p>if I use the function invoke, variable selected will return to  nil after giveapple finished since all the change was in another instance.<br />
Things works fine with activateWithTarget.</p>
<p>Is this a bug? Can anyone clarify this for me?</p>
<p>Cheers
</p></description>
		</item>

	</channel>
</rss>

