青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

隨筆 - 42  文章 - 3  trackbacks - 0
<2012年5月>
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789

常用鏈接

留言簿(2)

隨筆檔案

文章檔案

網(wǎng)頁收藏

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

Objective-C,is a reflective, object-oriented programming language that adds Smalltalk-style messaging to the C programming language.Today, it is used primarily on Apple's Mac OS X and iOS: two environments derived from the OpenStep standard, though not compliant with it.[1] Objective-C is the primary language used for Apple's Cocoa API, and it was originally the main language on NeXT's NeXTSTEP OS. Generic Objective-C programs that do not use these libraries can also be compiled for any system supported by gcc or Clang.

1. Define and implement a class
int the *.h file
@interface ClassName : ItsSuperclass
{
instance variable declarations
}
//method declarations
+ alloc; //class methods are preceded by a plus sign can be used by class objects,
- (void)display;// instance methods are marked with a minus sign can be used by  instances of class
Class methods are methods which are declared as static. The method can be called without creating an instance of the class. Class methods can only operate on class members and not on instance members as class methods are unaware of instance members. Instance methods of the class can also not be called from within a class method unless they are being called on an instance of that class.

Instance methods on the other hand require an instance of the class to exist before they can be called, so an instance of a class needs to be created by using the new keyword. Instance methods operate on specific instances of classes. Instance methods are not declared as static.

@end
in the *.m file
@implementation ClassName : ItsSuperclass
{
instance variable declarations
}
//method definitions
-(void)display
{ // implement }
@end

Declaring a Class, notes:
1 Every class should subclass NSObject;
2 class that inherits NSObject Provides a lot of basic functionality, including memory management;
3 No constructors but Apple uses conventional initializers
4 Override –[NSObject dealloc] to free resources and memory, Always call super’s implementation
Never access any ivar or call methods after the call to [super dealloc].
Never call dealloc directly!

2. Calling method
[object method];  
[object methodWithInput:input];

3.Creating Objects

example:NSString* myString = [[NSString alloc] init];

This is a nested method call. The first is the alloc method called on NSString itself. This is a relatively low-level call which reserves memory and instantiates an object.
The second piece is a call to init on the new object. The init implementation usually does basic setup, such as creating instance variables. The details of that are unknown to you as a client of the class.
In some cases, you may use a different version of init which takes input:
NSNumber* value = [[NSNumber alloc] initWithFloat:1.0];

4 Muti-input function
(method type) FuncName: (type of arg 1) name of arg1 Name of arg2: (type of arg2) arg3 name …. ;
example;
-(void) setKids: (NSString *)myOldestKidName secondKid: (NSString *) mySecondOldestKidName thirdKid: (NSString *) myThirdOldestKidName;

5 Difference between C and Objective C
BOOL,YES,NO:YES is equal to the true in C# or Java,NO is equal to false。But the value of YES is 1,NO is 0
nil means a null pointer.
”String” is a C string, @”"convert a C string to NSString.

define the access type:
@property( attributes) type name; attributes includes readwrite readonly assign retain copy noatomic
example: @property(readwrite, assign) int fido;
 

Basic Constructs

Objective-C Summary

Language Example Description
[ class_name method ];
object = [[ class_name alloc] init ];
object = [ class_name new ];
[ object method ];
[ object free ];
[ object release ];
class_name *object;
object = [[ class_name alloc] init ];
object = [ class_name new ];
[ object method ];
[ object free ];
[ object release ];
class_name *object;
Invoking methods. Some methods sent to class, some to object.
alloc/init are the same as new.

For objects derived from Object class.
For objects derived from NSObject.

You can’t instantiate an object on the stack; you can only have pointers to them.
@interface class_name : base_class
{
int data_member;
}
- (return_type) object_method;
+ (return_type) class_method;
@end
int data_member;
}
- (return_type) object_method;
+ (return_type) class_method;
@end
Class declaration.
@implementation class_name;
- (return_type) object_method
{
}
+ (return_type) class_method
{
}
@end
Class definition.
@class class_name; Forward declaration of class.
- (void) method;
[ object method ];
- (return_type) method: (type) arg;
val = [ object method:1 ];
- (void) method: (type) arg1 arg_name: (type) arg2;
[ object method:1 arg_name:2 ];
name is ìmethod:arg_name:î
[ object method ];
- (return_type) method: (type) arg;
val = [ object method:1 ];
- (void) method: (type) arg1 arg_name: (type) arg2;
[ object method:1 arg_name:2 ];
name is ìmethod:arg_name:î
No argument, no return.

Single argument with return value.


If more than one argument, their names are part of the method name. Using the names on calls is optional but recommended.

Use this name in @selector.
SEL selector = @selector(method);
SEL selector = @selector(method:);
SEL selector = @selector(method:arg:);

[ object perform:selector ];
Gives a selector to a method. If it has arguments they are part of the name. A method with one argument ends in a colon.


Invoke a method specified by a selector.
id
id object;
Object of any type; often used as a return value.
Notice no *: can hold an object of any type, but if you invoke a method it doesn't have, you crash.
#import An #include that's only included once.
self
[ self method ]
[ self class ]
[ self method ]
[ self class ]
The object whose method is being executed.
Invoke one of your own methods.
Returns the class you belong to; useful if you've been subclassed.
super
[ super method ];
[ super method ];
The parent object; always exists because everything is derived from Object or NSObject.
class_obj = [ class_name class ];
class_obj = [ object class ];
f = [ object isKindOf:class_obj ];
f = [ object isMemberOf:class_obj ];
f = [ object respondsTo:selector ];
f = [ class_name instancesRespondTo:selector ];
Gives the class object for the named class.
Gives the class object for the named object.
Is object a member of class_obj or one of its descendants?
Is object a member of class_obj ?
Can object respond to the method described by the selector?
Can instances of the given class respond to the method?
f = [ object isKindOfClass:class_obj ];
f = [ object isMemberOfClass:class_obj ];
f = [ object respondsToSelector:selector ];
f = [ object isMemberOfClass:class_obj ];
f = [ object respondsToSelector:selector ];
NSObject versions of the introspection messages.
@public
@protected
@private
@protected
@private
You can specify scope for data members only.
Allows access via object->data_member.
The default for instance variables.
Only methods of this class (not derived classes) can access this member.
@interface class_name(category)
@interface class_name(category) <protocol>
Categories define new methods or data members for an existing class.
You can override a method from the original class definition, but then that original is lost; subclassing might be better.
@protocol p1
- methods
@end
@protocol p1 <p2>
@interface class_name : base_class <p1, p2>
f = [ object conformsTo: @protocol(p1) ];
id <p1> object;
id <p1, p2> object;
@protocol p1 <p2>
@interface class_name : base_class <p1, p2>
f = [ object conformsTo: @protocol(p1) ];
id <p1> object;
id <p1, p2> object;
Protocols define a set of methods shared between classes. You must define these methods, but don't declare them in the interface.

A protocol can include another one.
This class is based on two protocols.
True if the object conforms to a protocol; if so you can use all its methods.

Restricts the object pointer to a type that conforms to these protocols.
@import url(http://m.shnenglu.com/cutesoft_client/cuteeditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
posted on 2012-05-18 14:31 鷹擊長空 閱讀(293) 評論(0)  編輯 收藏 引用

只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            午夜精品成人在线视频| 国产精品成人观看视频免费 | 亚洲国产精品电影| 亚洲美女视频网| 日韩午夜在线视频| 亚洲国产美女| 另类成人小视频在线| 久久全国免费视频| 亚洲高清一区二| 一本色道久久综合亚洲精品不| 亚洲性图久久| 久久久久久综合| 欧美日韩视频第一区| 国产精品九九| 狠狠色狠狠色综合日日小说| 日韩亚洲欧美成人| 欧美有码视频| 亚洲欧洲精品成人久久奇米网 | 久久久久亚洲综合| 免费成人小视频| 亚洲精品日韩精品| 亚洲欧美影院| 欧美激情综合亚洲一二区| 国产精品毛片a∨一区二区三区|国| 国产欧美一区二区精品仙草咪| 中国亚洲黄色| 免费h精品视频在线播放| 久久久久亚洲综合| 国产一区二区精品久久99| 一区二区三区亚洲| 亚洲午夜性刺激影院| 久久婷婷av| 一区二区三区**美女毛片| 久久精品亚洲精品国产欧美kt∨| 欧美精品一区二区三区久久久竹菊 | 欧美成人资源网| 国产伦精品一区二区三区照片91 | 国产精品自在在线| 最新中文字幕亚洲| 久久这里有精品15一区二区三区 | 欧美黄色aa电影| 黑人极品videos精品欧美裸| 亚洲在线免费观看| 亚洲精品视频免费| 欧美国产第二页| 永久555www成人免费| 午夜精品久久久久久久| 亚洲精品系列| 欧美激情2020午夜免费观看| 在线免费日韩片| 久久影音先锋| 久久精品123| 黄色日韩网站| 久久婷婷综合激情| 欧美亚洲在线观看| 国产伦精品一区二区三区免费迷 | 最新国产拍偷乱拍精品| 久久综合一区二区三区| 一区免费观看| 女人色偷偷aa久久天堂| 久久福利一区| 亚洲国产成人在线播放| 免费人成网站在线观看欧美高清 | 亚洲欧美久久久| 国产精品久久久久久久午夜片| 在线视频欧美日韩精品| 99综合在线| 国产精品老牛| 久久激情视频久久| 久久国产主播| 亚洲精品美女久久7777777| 亚洲国产高清自拍| 欧美日韩成人网| 亚洲欧美中文字幕| 亚洲国产天堂久久综合| 亚洲午夜一区二区| 欧美男人的天堂| 亚洲综合999| 午夜日韩在线观看| 一区二区三区在线免费视频| 免费观看一级特黄欧美大片| 久久综合中文| 在线视频日韩| 久久精品国产2020观看福利| 亚洲欧洲在线一区| 日韩视频在线观看免费| 国产精品久久久久久久一区探花| 久久久久久久久久久成人| 麻豆精品传媒视频| 亚洲一区二区视频在线观看| 亚洲欧美三级伦理| 亚洲人成网站999久久久综合| 99国产一区| 国产一区三区三区| 亚洲美洲欧洲综合国产一区| 国产一二三精品| 亚洲精品在线视频| 国产综合网站| 一本色道久久综合一区| 精品福利免费观看| 亚洲一区国产精品| 亚洲伦理网站| 久久久精品tv| 亚洲欧美国产日韩中文字幕| 久久综合九色综合久99| 性久久久久久久| 欧美精品午夜| 欧美a级在线| 国产欧美一区二区色老头| 亚洲韩国日本中文字幕| 黄色精品在线看| 亚洲欧美精品| 亚洲综合电影一区二区三区| 免费日韩成人| 噜噜爱69成人精品| 国产日产欧美a一级在线| 99riav1国产精品视频| 亚洲人成在线免费观看| 久久精品视频在线| 欧美中文在线观看| 国产精品久久77777| 亚洲欧洲一区二区三区在线观看| 伊人精品在线| 久久精品视频va| 欧美在线视频全部完| 欧美日韩中文字幕| 亚洲毛片网站| 亚洲精品影院| 欧美福利电影网| 欧美大胆成人| 激情亚洲一区二区三区四区| 午夜激情亚洲| 午夜视黄欧洲亚洲| 国产精品扒开腿做爽爽爽软件 | 好看不卡的中文字幕| 亚洲综合成人在线| 亚洲综合日韩中文字幕v在线| 伊人成年综合电影网| 欧美91大片| 在线成人亚洲| 久久久综合网站| 久久综合亚洲社区| 国产一区二区三区高清播放| 欧美亚洲视频在线观看| 久久久噜噜噜久噜久久| 精品999在线播放| 久久午夜色播影院免费高清| 欧美h视频在线| 亚洲激情在线观看| 欧美日韩大片一区二区三区| aa级大片欧美三级| 中文国产成人精品| 国产精品视频福利| 久久激情综合| 91久久国产综合久久91精品网站| 99日韩精品| 国产精品乱码| 久久岛国电影| 亚洲国产精品女人久久久| 亚洲午夜性刺激影院| 国产一区二区三区高清| 欧美国产视频一区二区| 夜夜狂射影院欧美极品| 久久国产一区| 日韩视频在线观看| 国产美女精品在线| 久久亚洲私人国产精品va媚药 | 久久综合激情| 亚洲精品免费网站| 国产精品国产三级国产 | 亚洲一区二区黄色| 欧美1区2区3区| 中国亚洲黄色| 在线日韩欧美视频| 欧美美女bbbb| 久久xxxx| av成人黄色| 男男成人高潮片免费网站| 亚洲亚洲精品三区日韩精品在线视频 | 新狼窝色av性久久久久久| 欧美国内亚洲| 欧美一区二区三区在线观看| 亚洲欧洲在线免费| 国内精品亚洲| 国产精品久久久| 蜜臀av在线播放一区二区三区 | 欧美日韩午夜剧场| 久久久久综合| 西瓜成人精品人成网站| 99视频一区二区| 欧美国产日韩一区二区在线观看| 亚洲欧美日韩国产成人精品影院| 亚洲激情电影在线| 国产专区欧美精品| 国产精品亚洲美女av网站| 欧美日韩卡一卡二| 欧美高清影院| 免费观看成人鲁鲁鲁鲁鲁视频| 欧美在线999| 午夜精品福利在线|