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

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

常用鏈接

留言簿(2)

隨筆檔案

文章檔案

網頁收藏

搜索

  •  

最新評論

閱讀排行榜

評論排行榜

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 鷹擊長空 閱讀(297) 評論(0)  編輯 收藏 引用

只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   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>
            亚洲人www| 亚洲一区二区在线免费观看| 亚洲性xxxx| 国产一区二区主播在线| 免费一级欧美片在线观看| 欧美激情亚洲自拍| 欧美中文日韩| 欧美成人免费网站| 午夜在线电影亚洲一区| 美女网站久久| 午夜视频久久久| 欧美大片免费观看在线观看网站推荐| 午夜国产精品视频免费体验区| 久久久久久91香蕉国产| 亚洲欧美日韩一区在线| 欧美 日韩 国产在线 | 日韩视频在线免费观看| 国产一区二区三区久久久| 亚洲精品免费观看| 狠狠色综合播放一区二区| 亚洲久色影视| 亚洲国产精品精华液2区45| 香蕉久久一区二区不卡无毒影院 | 欧美一区二区| 亚洲一区二区在线看| 裸体一区二区三区| 久久免费午夜影院| 国产精品一区二区在线观看| 亚洲欧洲另类| 亚洲电影成人| 久久精品国产精品亚洲综合| 亚洲欧美怡红院| 欧美视频免费| 亚洲美女中文字幕| 亚洲美女免费精品视频在线观看| 久久精品72免费观看| 欧美一区国产二区| 国产精品美女主播| 亚洲香蕉成视频在线观看| 中日韩高清电影网| 欧美日韩不卡| 亚洲精品视频免费在线观看| 亚洲欧洲综合另类在线| 欧美国产日本在线| 亚洲国产免费看| 亚洲精品久久久蜜桃| 免费精品视频| 欧美激情一区二区三级高清视频| 亚洲成人在线| 欧美暴力喷水在线| 91久久精品国产91性色| 亚洲日本在线观看| 欧美精品色网| av成人手机在线| 亚洲欧美偷拍卡通变态| 久久免费视频这里只有精品| 久久国产手机看片| 看片网站欧美日韩| 亚洲第一区在线| 久久亚洲色图| 亚洲激情在线观看| 一本高清dvd不卡在线观看| 欧美人与性禽动交情品 | 激情小说亚洲一区| 久久久999精品视频| 欧美a级片网站| 99视频超级精品| 国产精品国产三级国产普通话三级 | 久久国产高清| 欧美 日韩 国产一区二区在线视频 | 久久免费少妇高潮久久精品99| 黄色一区二区在线| 欧美电影专区| 亚洲伊人观看| 欧美xx69| 亚洲特级片在线| 国产一区二区精品在线观看| 久久精品1区| 亚洲精品视频在线播放| 午夜日韩激情| 亚洲精品国产视频| 国产精品区一区二区三| 久久久成人精品| 99国产一区| 久久综合福利| 亚洲免费在线视频| 在线观看视频一区| 国产精品成人在线观看| 久久久久在线| 亚洲少妇在线| 亚洲电影免费观看高清完整版| 亚洲视频 欧洲视频| 狠狠v欧美v日韩v亚洲ⅴ| 欧美巨乳在线观看| 久久精品国产欧美激情| 亚洲毛片一区二区| 久久综合999| 午夜一区在线| 国产精品99久久久久久www| 一区二区在线观看视频在线观看| 欧美日韩18| 久久人人爽人人爽爽久久| 亚洲色无码播放| 亚洲人成网在线播放| 老司机午夜免费精品视频| 亚洲综合日韩| 99国内精品| 亚洲第一偷拍| 国产一区二区三区视频在线观看 | 六月天综合网| 久久av最新网址| 亚洲欧美国产精品va在线观看| 亚洲激情在线激情| 激情欧美一区二区三区| 国产日韩欧美自拍| 午夜精品久久一牛影视| 亚洲电影观看| 国产日韩欧美在线视频观看| 欧美日韩国产一级片| 两个人的视频www国产精品| 亚洲欧美在线播放| 一区二区三区高清在线观看| 亚洲国产成人精品视频| 麻豆精品视频在线| 久久精品论坛| 久久精品女人| 欧美一区亚洲| 久久精品国产久精国产一老狼| 亚洲免费网站| 亚洲一区二区三区高清不卡| 99re6这里只有精品| 亚洲激情二区| 亚洲激情在线激情| 亚洲国产精品高清久久久| 亚洲国产精品ⅴa在线观看 | 亚洲免费观看在线视频| 亚洲国产你懂的| 亚洲高清一区二| 欧美国产大片| 亚洲黄色有码视频| 亚洲第一视频网站| 亚洲国产天堂久久综合网| 亚洲激情在线| 夜夜嗨av一区二区三区网页| 一本色道久久综合一区| 国产精品99久久久久久人| 亚洲一区二区不卡免费| 亚洲男人第一av网站| 欧美在线不卡视频| 老司机免费视频一区二区三区| 麻豆精品精华液| 欧美久久一级| 国产精品专区一| 激情欧美一区二区三区| 91久久线看在观草草青青| av成人黄色| 欧美一区二区精品在线| 久久人体大胆视频| 欧美激情一区二区三区四区| 亚洲片区在线| 亚洲制服av| 久久综合精品国产一区二区三区| 麻豆国产精品777777在线| 欧美日韩精品久久| 国产欧美日韩三区| 亚洲国产精品www| 亚洲婷婷综合久久一本伊一区| 午夜国产精品视频| 欧美大片一区| 亚洲视频1区| 久久视频这里只有精品| 欧美精品一区二区三区蜜桃| 国产精品日日摸夜夜摸av| 一区二区在线观看视频在线观看 | 久热精品在线视频| 欧美视频在线观看| 极品日韩av| 亚洲小说欧美另类婷婷| 久久久www成人免费精品| 欧美成人午夜免费视在线看片| 亚洲人在线视频| 欧美一级淫片aaaaaaa视频| 欧美福利视频在线| 国产视频亚洲| 日韩午夜免费| 蜜桃久久av一区| 亚洲欧美大片| 欧美日韩国产探花| 亚洲国产一区在线| 欧美一区亚洲| 日韩视频一区| 麻豆国产va免费精品高清在线| 国产精品免费一区二区三区观看| 亚洲国产日韩在线一区模特| 欧美在线网址| 欧美激情一区二区在线| 欧美第一黄色网| 午夜欧美精品| 欧美色图麻豆| 亚洲精品久久久久久下一站|