<?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: Objective-C Programming Part II.</title>
	<atom:link href="http://www.macfeteria.com/blog/2008/02/23/objective-c-programming-part-ii/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.macfeteria.com/blog/2008/02/23/objective-c-programming-part-ii/</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: kantae</title>
		<link>http://www.macfeteria.com/blog/2008/02/23/objective-c-programming-part-ii/comment-page-1/#comment-245</link>
		<dc:creator>kantae</dc:creator>
		<pubDate>Sat, 17 Sep 2011 14:36:41 +0000</pubDate>
		<guid isPermaLink="false">http://maccafe.wordpress.com/?p=7#comment-245</guid>
		<description>ถ้าผมลืม release มันจะค้างในหน่วยความจำจนถึงตอนไหน
และสงผลกับโปรแกรมร้ายแรงไหมครับ</description>
		<content:encoded><![CDATA[<p>ถ้าผมลืม release มันจะค้างในหน่วยความจำจนถึงตอนไหน<br />
และสงผลกับโปรแกรมร้ายแรงไหมครับ</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: deen05</title>
		<link>http://www.macfeteria.com/blog/2008/02/23/objective-c-programming-part-ii/comment-page-1/#comment-235</link>
		<dc:creator>deen05</dc:creator>
		<pubDate>Sat, 23 Jul 2011 04:41:04 +0000</pubDate>
		<guid isPermaLink="false">http://maccafe.wordpress.com/?p=7#comment-235</guid>
		<description>บทความเข้าใจง่ายดีครับ
เริ่มรู้สึกว่ามันคล้าย JAVA แล้ว</description>
		<content:encoded><![CDATA[<p>บทความเข้าใจง่ายดีครับ<br />
เริ่มรู้สึกว่ามันคล้าย JAVA แล้ว</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.macfeteria.com/blog/2008/02/23/objective-c-programming-part-ii/comment-page-1/#comment-173</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Wed, 20 Jan 2010 09:53:11 +0000</pubDate>
		<guid isPermaLink="false">http://maccafe.wordpress.com/?p=7#comment-173</guid>
		<description>ครับผม ขอบคุณครับ</description>
		<content:encoded><![CDATA[<p>ครับผม ขอบคุณครับ</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: biggoogle</title>
		<link>http://www.macfeteria.com/blog/2008/02/23/objective-c-programming-part-ii/comment-page-1/#comment-172</link>
		<dc:creator>biggoogle</dc:creator>
		<pubDate>Sat, 16 Jan 2010 03:52:09 +0000</pubDate>
		<guid isPermaLink="false">http://maccafe.wordpress.com/?p=7#comment-172</guid>
		<description>บรรทัด
- (void) setPrice: (float) p;
ในส่วนของ setPrice นั้นมีการส่งค่ากลับเป็นแบบ void เหมือนกัน แต่ว่าสิ่งที่ต่างจาก printDetail คือ มีการรับ parameter เข้าไปด้วย โดยรับเข้าไปเป็น int และให้ parameter นี้ชื่อว่า p

มันผิดมั๊งครับ

- (void) setPrice: (float) p;
ในส่วนของ setPrice นั้นมีการส่งค่ากลับเป็นแบบ void เหมือนกัน แต่ว่าสิ่งที่ต่างจาก printDetail คือ มีการรับ parameter เข้าไปด้วย โดยรับเข้าไปเป็น float และให้ parameter นี้ชื่อว่า p

ใช่มั๊ยครับ</description>
		<content:encoded><![CDATA[<p>บรรทัด<br />
- (void) setPrice: (float) p;<br />
ในส่วนของ setPrice นั้นมีการส่งค่ากลับเป็นแบบ void เหมือนกัน แต่ว่าสิ่งที่ต่างจาก printDetail คือ มีการรับ parameter เข้าไปด้วย โดยรับเข้าไปเป็น int และให้ parameter นี้ชื่อว่า p</p>
<p>มันผิดมั๊งครับ</p>
<p>- (void) setPrice: (float) p;<br />
ในส่วนของ setPrice นั้นมีการส่งค่ากลับเป็นแบบ void เหมือนกัน แต่ว่าสิ่งที่ต่างจาก printDetail คือ มีการรับ parameter เข้าไปด้วย โดยรับเข้าไปเป็น float และให้ parameter นี้ชื่อว่า p</p>
<p>ใช่มั๊ยครับ</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.macfeteria.com/blog/2008/02/23/objective-c-programming-part-ii/comment-page-1/#comment-28</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Sun, 02 Mar 2008 05:15:27 +0000</pubDate>
		<guid isPermaLink="false">http://maccafe.wordpress.com/?p=7#comment-28</guid>
		<description>คือเวลาเราประกาศ properties เนี่ยมันจะมี 2 อย่างคือ @synthesize กับ @dynamic แล้ว synthesize มันเหมือนเป็นการบอกว่า ให้ Compiler เขียน code ในส่วนของ get/set น่ะครับ

คือถ้าจะเอา code มาเปรียบเทียบให้เห็นอาจจะเข้าใจง่ายกว่า

@interface MyClass : NSObject
{
    NSString *value;
}
@property(copy, readwrite) NSString *value;
@end

// assume using garbage collection
@implementation MyClass
@synthesize value;
@end


ถ้าเป็น dynamic จะได้ว่า


@interface MyClass : NSObject
{
    NSString *value;
}
@property(copy, readwrite) NSString *value;
@end


// assume using garbage collection
@implementation MyClass
@dynamic value;
- (NSString *)value {
    return value;
}
- (void)setValue:(NSString *)newValue {
    if (newValue != value) {
        value = [newValue copy];
    }
}
@end


ถ้าเราประกาศให้เป็น synthesize จะเห็นว่า code มันสั้นกว่า
เราไม่ต้องไป implement มันเหมือน dynamic หลังจากประกาศ synthesize แล้ว เราก็สามารถใช้ได้เลย

เช่นว่า

MyClass *myInstance = [[MyClass alloc] init];
myInstance.value = @&quot;New value&quot;;
NSLog(@&quot;myInstance value: %@&quot;, myInstance.value);

น่าจะพอเข้าใจน่ะครับ</description>
		<content:encoded><![CDATA[<p>คือเวลาเราประกาศ properties เนี่ยมันจะมี 2 อย่างคือ @synthesize กับ @dynamic แล้ว synthesize มันเหมือนเป็นการบอกว่า ให้ Compiler เขียน code ในส่วนของ get/set น่ะครับ</p>
<p>คือถ้าจะเอา code มาเปรียบเทียบให้เห็นอาจจะเข้าใจง่ายกว่า</p>
<p>@interface MyClass : NSObject<br />
{<br />
    NSString *value;<br />
}<br />
@property(copy, readwrite) NSString *value;<br />
@end</p>
<p>// assume using garbage collection<br />
@implementation MyClass<br />
@synthesize value;<br />
@end</p>
<p>ถ้าเป็น dynamic จะได้ว่า</p>
<p>@interface MyClass : NSObject<br />
{<br />
    NSString *value;<br />
}<br />
@property(copy, readwrite) NSString *value;<br />
@end</p>
<p>// assume using garbage collection<br />
@implementation MyClass<br />
@dynamic value;<br />
- (NSString *)value {<br />
    return value;<br />
}<br />
- (void)setValue:(NSString *)newValue {<br />
    if (newValue != value) {<br />
        value = [newValue copy];<br />
    }<br />
}<br />
@end</p>
<p>ถ้าเราประกาศให้เป็น synthesize จะเห็นว่า code มันสั้นกว่า<br />
เราไม่ต้องไป implement มันเหมือน dynamic หลังจากประกาศ synthesize แล้ว เราก็สามารถใช้ได้เลย</p>
<p>เช่นว่า</p>
<p>MyClass *myInstance = [[MyClass alloc] init];<br />
myInstance.value = @&#8221;New value&#8221;;<br />
NSLog(@&#8221;myInstance value: %@&#8221;, myInstance.value);</p>
<p>น่าจะพอเข้าใจน่ะครับ</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: alvanzoe</title>
		<link>http://www.macfeteria.com/blog/2008/02/23/objective-c-programming-part-ii/comment-page-1/#comment-27</link>
		<dc:creator>alvanzoe</dc:creator>
		<pubDate>Sat, 01 Mar 2008 10:58:10 +0000</pubDate>
		<guid isPermaLink="false">http://maccafe.wordpress.com/?p=7#comment-27</guid>
		<description>@synthesize นี้มันคืออะไรหรอ ครับ Tutorial Cocoa ของ Apple พางง นิดหน่อย</description>
		<content:encoded><![CDATA[<p>@synthesize นี้มันคืออะไรหรอ ครับ Tutorial Cocoa ของ Apple พางง นิดหน่อย</p>
]]></content:encoded>
	</item>
</channel>
</rss>

