<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>梁剑的Blog &#187; ObjC</title>
	<atom:link href="http://icomes.net/tag/objc/feed/" rel="self" type="application/rss+xml" />
	<link>http://icomes.net</link>
	<description>做有趣的事，做有用的人</description>
	<lastBuildDate>Sat, 05 Nov 2011 18:23:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>从c++到Objective-C</title>
		<link>http://icomes.net/2009/12/27/%e4%bb%8ec%e5%88%b0objective-c/</link>
		<comments>http://icomes.net/2009/12/27/%e4%bb%8ec%e5%88%b0objective-c/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 14:53:06 +0000</pubDate>
		<dc:creator>梁剑</dc:creator>
				<category><![CDATA[技术笔记]]></category>
		<category><![CDATA[ObjC]]></category>

		<guid isPermaLink="false">http://icomes.net/?p=475</guid>
		<description><![CDATA[1. 头文件依然是.h 2. .cpp变成了.m 3. #import代替了#include，#import保证只会引用一次，相当于.h里的#ifndef #define #endif模式 4. 用@interface &#8230; @end来声明类，取代class ClassName{} 5. 用@implementation &#8230; @end来实现类 6. Data Members放在@interface ClassName : Parent{ &#8230; }中，默认权限为@protected，在ObjC里称为Instance Variables 7. Member Functions放在@interface ClassName: Parent{} &#8230; @end中，在ObjC里称为Instance Methods 8. Instance Methods的声明方式为：scope (returnType) methodName: (parameter1Type) parameter1Name; 9. scope分instance和class两种，分别用-和+表示 10. 调用method的方式是[object method]，相当于object-&#62;method() 11. 带参数调用method的方式是[object method: parameter] 12. 没有Object，只有Pointer to Object 13. [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2007%2F09%2F15%2Fc-common-knowledge%2F&from=http%3A%2F%2Ficomes.net%2F2009%2F12%2F27%2F%25E4%25BB%258Ec%25E5%2588%25B0objective-c%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">C++ Common Knowledge</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2008%2F01%2F08%2Fc%25E4%25B8%25AD%25EF%25BC%258C%25E6%259E%2584%25E9%2580%25A0%25E5%2587%25BD%25E6%2595%25B0%25E4%25B8%25AD%25E4%25B8%258D%25E8%2583%25BD%25E8%25B0%2583%25E7%2594%25A8%25E5%2590%258C%25E5%2590%258D%25E7%259A%2584%25E5%258F%25A6%25E4%25B8%2580%25E4%25B8%25AA%25E6%259E%2584%25E9%2580%25A0%25E5%2587%25BD%25E6%2595%25B0%2F&from=http%3A%2F%2Ficomes.net%2F2009%2F12%2F27%2F%25E4%25BB%258Ec%25E5%2588%25B0objective-c%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">C++中，构造函数中不能调用同名的另一个构造函数</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2008%2F12%2F10%2Fc%25E7%25AE%25B4%25E8%25A8%2580%25EF%25BC%259A%25E7%2590%2586%25E8%25A7%25A3typename%25E7%259A%2584%25E4%25B8%25A4%25E4%25B8%25AA%25E5%2590%25AB%25E4%25B9%2589%2F&from=http%3A%2F%2Ficomes.net%2F2009%2F12%2F27%2F%25E4%25BB%258Ec%25E5%2588%25B0objective-c%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">C++箴言：理解typename的两个含义</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2007%2F11%2F15%2F%25E9%2580%259A%25E9%2585%258Dcpp%25E5%2592%258Cc%25E7%259A%2584makefile%2F&from=http%3A%2F%2Ficomes.net%2F2009%2F12%2F27%2F%25E4%25BB%258Ec%25E5%2588%25B0objective-c%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">通配.cpp和.c的Makefile</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>1. 头文件依然是.h<br />
2. .cpp变成了.m<br />
3. #import代替了#include，#import保证只会引用一次，相当于.h里的#ifndef #define #endif模式<br />
4. 用@interface &#8230; @end来声明类，取代class ClassName{}<br />
5. 用@implementation &#8230; @end来实现类<br />
6. Data Members放在@interface ClassName : Parent{ &#8230; }中，默认权限为@protected，在ObjC里称为Instance Variables<br />
7. Member Functions放在@interface ClassName: Parent{} &#8230; @end中，在ObjC里称为Instance Methods<br />
8. Instance Methods的声明方式为：scope (returnType) methodName: (parameter1Type) parameter1Name;<br />
9. scope分instance和class两种，分别用-和+表示<br />
10. 调用method的方式是[object method]，相当于object-&gt;method()<br />
11. 带参数调用method的方式是[object method: parameter]<br />
12. 没有Object，只有Pointer to Object<br />
13. 通常的构造方式： Object * obj = [[Object alloc] init]<br />
14. 析构的方式：[obj release]15.多参数method的声明方式： scope (returnType) methodName: (parameter1Type) parameter1Name label1Name: (parameter2Type) parameter2Name &#8230; ;<br />
16. labelName不是必须的<br />
17. 这种特别的语法源自SmallTalk<br />
18. private: [list of vars] protected: [list of vars] public: [list of vars] 改成了@private, @protected, @public<br />
19. Class Variable用static的方法实现⋯⋯<br />
20. +(void) initialize 会在构造的时候被调用<br />
21. ObjC通常用@符号表示语言的衍生部分<br />
22. ObjC用id来表示范型对象的指针<br />
23. 支持动态类型识别<br />
24. Categories机制可用于不继承已有class的前提下加入新功能<br />
25. Posing机制允许Child取代Parent<br />
26. Protocol相当于pure virtual class<br />
27. ObjC由两种内存管理的方法，1) retain and release，2) retain and release/autorelease<br />
28. Foundation相当于STL，NSArray对应vector，NSDictionary对应map<br />
29. ObjC不支持Namespace<br />
30. 不支持重载</p>
<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2007%2F09%2F15%2Fc-common-knowledge%2F&from=http%3A%2F%2Ficomes.net%2F2009%2F12%2F27%2F%25E4%25BB%258Ec%25E5%2588%25B0objective-c%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">C++ Common Knowledge</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2008%2F01%2F08%2Fc%25E4%25B8%25AD%25EF%25BC%258C%25E6%259E%2584%25E9%2580%25A0%25E5%2587%25BD%25E6%2595%25B0%25E4%25B8%25AD%25E4%25B8%258D%25E8%2583%25BD%25E8%25B0%2583%25E7%2594%25A8%25E5%2590%258C%25E5%2590%258D%25E7%259A%2584%25E5%258F%25A6%25E4%25B8%2580%25E4%25B8%25AA%25E6%259E%2584%25E9%2580%25A0%25E5%2587%25BD%25E6%2595%25B0%2F&from=http%3A%2F%2Ficomes.net%2F2009%2F12%2F27%2F%25E4%25BB%258Ec%25E5%2588%25B0objective-c%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">C++中，构造函数中不能调用同名的另一个构造函数</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2008%2F12%2F10%2Fc%25E7%25AE%25B4%25E8%25A8%2580%25EF%25BC%259A%25E7%2590%2586%25E8%25A7%25A3typename%25E7%259A%2584%25E4%25B8%25A4%25E4%25B8%25AA%25E5%2590%25AB%25E4%25B9%2589%2F&from=http%3A%2F%2Ficomes.net%2F2009%2F12%2F27%2F%25E4%25BB%258Ec%25E5%2588%25B0objective-c%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">C++箴言：理解typename的两个含义</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Ficomes.net%2F2007%2F11%2F15%2F%25E9%2580%259A%25E9%2585%258Dcpp%25E5%2592%258Cc%25E7%259A%2584makefile%2F&from=http%3A%2F%2Ficomes.net%2F2009%2F12%2F27%2F%25E4%25BB%258Ec%25E5%2588%25B0objective-c%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">通配.cpp和.c的Makefile</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://icomes.net/2009/12/27/%e4%bb%8ec%e5%88%b0objective-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

