<?xml version="1.0" encoding="UTF-8"?><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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Ojective-C Programming &#8211; Thread</title>
	<atom:link href="http://www.macfeteria.com/blog/2008/06/09/ojective-c-programming-thread/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.macfeteria.com/blog/2008/06/09/ojective-c-programming-thread/</link>
	<description>All About Mac and iPhone Programming</description>
	<lastBuildDate>Sat, 17 Sep 2011 15:01:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
	<item>
		<title>By: admin</title>
		<link>http://www.macfeteria.com/blog/2008/06/09/ojective-c-programming-thread/comment-page-1/#comment-113</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Thu, 25 Jun 2009 17:11:48 +0000</pubDate>
		<guid isPermaLink="false">http://maccafe.wordpress.com/?p=68#comment-113</guid>
		<description>จริงๆแล้ว selector มันคือ pointer to function นะครับ ดูตัวอย่าง code ต่อไปนี้

@interface Student : NSObject {}
-(void) setName:(NSString*)name;
@end

สมมติว่าเราต้องการให้ ใส่ชื่อนักเรียน ถ้าหากเขียน แบบปกติก็จะได้ว่า
[student setName::@&quot;Ter&quot;];


ถ้าหากเขียนแบบใช้ selector ก็จะได้ว่า
[student performSelector:@selector(setName:) withObject:@&quot;Ter&quot;];

------------------------

ฉนั้นแล้วคำถามว่า มันคล้ายๆกับการแตก thread หรือเปล่า สรุปง่ายๆคือไม่ใช่การสร้าง แต่เป็นการบอกให้ thread ที่จะสร้างรู้ว่าจะไปทำงาน function ไหน )

[NSThread detachNewThreadSelector:@selector(PrintToConsole: )  
                                  toTarget:sampleConsole 
                                  withObject:@&quot;Hello&quot;];  

จาก code ข้างบนเราสร้าง thread ขึ้นมาแล้วหลังจากนั้นเราก็ใช้ pointer ( selector ) ไปยัง function ที่ชื่อ PrintToConsole:  โดยส่ง &quot;Hello&quot; ให้กับ thread เอาไปใช้ในฟังชั่น PrintToConsole ไงครับ</description>
		<content:encoded><![CDATA[<p>จริงๆแล้ว selector มันคือ pointer to function นะครับ ดูตัวอย่าง code ต่อไปนี้</p>
<p>@interface Student : NSObject {}<br />
-(void) setName:(NSString*)name;<br />
@end</p>
<p>สมมติว่าเราต้องการให้ ใส่ชื่อนักเรียน ถ้าหากเขียน แบบปกติก็จะได้ว่า<br />
[student setName::@"Ter"];</p>
<p>ถ้าหากเขียนแบบใช้ selector ก็จะได้ว่า<br />
[student performSelector:@selector(setName:) withObject:@"Ter"];</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>ฉนั้นแล้วคำถามว่า มันคล้ายๆกับการแตก thread หรือเปล่า สรุปง่ายๆคือไม่ใช่การสร้าง แต่เป็นการบอกให้ thread ที่จะสร้างรู้ว่าจะไปทำงาน function ไหน )</p>
<p>[NSThread detachNewThreadSelector:@selector(PrintToConsole: )<br />
                                  toTarget:sampleConsole<br />
                                  withObject:@"Hello"];  </p>
<p>จาก code ข้างบนเราสร้าง thread ขึ้นมาแล้วหลังจากนั้นเราก็ใช้ pointer ( selector ) ไปยัง function ที่ชื่อ PrintToConsole:  โดยส่ง &#8220;Hello&#8221; ให้กับ thread เอาไปใช้ในฟังชั่น PrintToConsole ไงครับ</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: skyper_v</title>
		<link>http://www.macfeteria.com/blog/2008/06/09/ojective-c-programming-thread/comment-page-1/#comment-112</link>
		<dc:creator>skyper_v</dc:creator>
		<pubDate>Wed, 24 Jun 2009 09:52:12 +0000</pubDate>
		<guid isPermaLink="false">http://maccafe.wordpress.com/?p=68#comment-112</guid>
		<description>งง มานานนมากก
กับ @selector Method ช่วย เคลียให้ผมที
ว่ามันเป็นยังไง ใช้ยังไง
ผมลองใช้แล้ว ได้บ้าง ไม่ได้บ้าง

มันคล้่ายๆแตก thread ไปทำปะครับ
แต่ก็งงๆกับการส่ง parameter ไปให้กับตัว @selector อยู่ครับ</description>
		<content:encoded><![CDATA[<p>งง มานานนมากก<br />
กับ @selector Method ช่วย เคลียให้ผมที<br />
ว่ามันเป็นยังไง ใช้ยังไง<br />
ผมลองใช้แล้ว ได้บ้าง ไม่ได้บ้าง</p>
<p>มันคล้่ายๆแตก thread ไปทำปะครับ<br />
แต่ก็งงๆกับการส่ง parameter ไปให้กับตัว @selector อยู่ครับ</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: say_hi</title>
		<link>http://www.macfeteria.com/blog/2008/06/09/ojective-c-programming-thread/comment-page-1/#comment-49</link>
		<dc:creator>say_hi</dc:creator>
		<pubDate>Thu, 19 Jun 2008 10:38:46 +0000</pubDate>
		<guid isPermaLink="false">http://maccafe.wordpress.com/?p=68#comment-49</guid>
		<description>ขอบคุณครับ เล็งๆไว้ว่าจะสั่ง Amazon นะครับ
เก็บไว้เป็น Reference ครับ ตอนนี้พยายามตระเวณเอา
กับฝาหรั่งใน Web พยายามดูดๆๆ ดูดซับอะครับ อยากให้
คนไทยเป็นแบบฝรั่งนะครับ คือความรู้ก็ Share กานนะครับ
เอาแบบสนุกๆ ใจรักครับ เงินตามมาเองเนอะ</description>
		<content:encoded><![CDATA[<p>ขอบคุณครับ เล็งๆไว้ว่าจะสั่ง Amazon นะครับ<br />
เก็บไว้เป็น Reference ครับ ตอนนี้พยายามตระเวณเอา<br />
กับฝาหรั่งใน Web พยายามดูดๆๆ ดูดซับอะครับ อยากให้<br />
คนไทยเป็นแบบฝรั่งนะครับ คือความรู้ก็ Share กานนะครับ<br />
เอาแบบสนุกๆ ใจรักครับ เงินตามมาเองเนอะ</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: say_hi</title>
		<link>http://www.macfeteria.com/blog/2008/06/09/ojective-c-programming-thread/comment-page-1/#comment-47</link>
		<dc:creator>say_hi</dc:creator>
		<pubDate>Sat, 14 Jun 2008 03:33:45 +0000</pubDate>
		<guid isPermaLink="false">http://maccafe.wordpress.com/?p=68#comment-47</guid>
		<description>ช่วยแนะนำหนังสือเกี่ยวกับ Objective-C แบบ Intermediate and Advance ดีให้หน่อยครับ อยากได้ครับ</description>
		<content:encoded><![CDATA[<p>ช่วยแนะนำหนังสือเกี่ยวกับ Objective-C แบบ Intermediate and Advance ดีให้หน่อยครับ อยากได้ครับ</p>
]]></content:encoded>
	</item>
</channel>
</rss>

