- 浏览: 39904 次
- 性别:
- 来自: 北京
最近访客 更多访客>>
文章分类
最新评论
-
chenniaoc:
http://www.techotopia.com/index ...
objective-c NSString 使用详细指南
Writability
These attributes specify whether or not a property has an associated set accessor. They are mutually exclusive.
readwrite
Indicates that the property should be treated as read/write. This is the default.
Both a getter and setter method will be required in the @implementation. If you use @synthesize in the implementation block, the getter and setter methods are synthesized.
readonly
Indicates that the property is read-only.
If you specify readonly, only a getter method is required in the @implementation. If you use @synthesize in the implementation block, only the getter method is synthesized. Moreover, if you attempt to assign a value using the dot syntax, you get a compiler error.
Setter Semantics
These attributes specify the semantics of a set accessor. They are mutually exclusive.
assign
Specifies that the setter uses simple assignment. This is the default.
You typically use this attribute for scalar types such as NSInteger and CGRect, or (in a reference-counted environment) for objects you don’t own such as delegates.
retain and assign are effectively the same in a garbage-collected environment.
retain
Specifies that retain should be invoked on the object upon assignment. (The default is assign.)
The previous value is sent a release message.
Prior to Mac OS X v10.6, this attribute is valid only for Objective-C object types (so you cannot specify retain for Core Foundation objects—see “Core Foundation”).
On Mac OS X v10.6 and later, you can use the __attribute__ keyword to specify that a Core Foundation property should be treated like an Objective-C object for memory management, as illustrated in this example:
@property(retain) __attribute__((NSObject)) CFDictionaryRef myDictionary;
copy
Specifies that a copy of the object should be used for assignment. (The default is assign.)
The previous value is sent a release message.
The copy is made by invoking the copy method. This attribute is valid only for object types, which must implement the NSCopying protocol. For further discussion, see “Copy.”
Different constraints apply depending on whether or not you use garbage collection:
*
If you do not use garbage collection, for object properties you must explicitly specify one of assign, retain or copy—otherwise you will get a compiler warning. (This encourages you to think about what memory management behavior you want and type it explicitly.)
To decide which you should choose, you need to understand Cocoa’s memory management policy (see Memory Management Programming Guide).
*
If you use garbage collection, you don't get a warning if you use the default (that is, if you don’t specify any of assign, retain or copy) unless the property's type is a class that conforms to NSCopying. The default is usually what you want; if the property type can be copied, however, to preserve encapsulation you often want to make a private copy of the object.
These attributes specify whether or not a property has an associated set accessor. They are mutually exclusive.
readwrite
Indicates that the property should be treated as read/write. This is the default.
Both a getter and setter method will be required in the @implementation. If you use @synthesize in the implementation block, the getter and setter methods are synthesized.
readonly
Indicates that the property is read-only.
If you specify readonly, only a getter method is required in the @implementation. If you use @synthesize in the implementation block, only the getter method is synthesized. Moreover, if you attempt to assign a value using the dot syntax, you get a compiler error.
Setter Semantics
These attributes specify the semantics of a set accessor. They are mutually exclusive.
assign
Specifies that the setter uses simple assignment. This is the default.
You typically use this attribute for scalar types such as NSInteger and CGRect, or (in a reference-counted environment) for objects you don’t own such as delegates.
retain and assign are effectively the same in a garbage-collected environment.
retain
Specifies that retain should be invoked on the object upon assignment. (The default is assign.)
The previous value is sent a release message.
Prior to Mac OS X v10.6, this attribute is valid only for Objective-C object types (so you cannot specify retain for Core Foundation objects—see “Core Foundation”).
On Mac OS X v10.6 and later, you can use the __attribute__ keyword to specify that a Core Foundation property should be treated like an Objective-C object for memory management, as illustrated in this example:
@property(retain) __attribute__((NSObject)) CFDictionaryRef myDictionary;
copy
Specifies that a copy of the object should be used for assignment. (The default is assign.)
The previous value is sent a release message.
The copy is made by invoking the copy method. This attribute is valid only for object types, which must implement the NSCopying protocol. For further discussion, see “Copy.”
Different constraints apply depending on whether or not you use garbage collection:
*
If you do not use garbage collection, for object properties you must explicitly specify one of assign, retain or copy—otherwise you will get a compiler warning. (This encourages you to think about what memory management behavior you want and type it explicitly.)
To decide which you should choose, you need to understand Cocoa’s memory management policy (see Memory Management Programming Guide).
*
If you use garbage collection, you don't get a warning if you use the default (that is, if you don’t specify any of assign, retain or copy) unless the property's type is a class that conforms to NSCopying. The default is usually what you want; if the property type can be copied, however, to preserve encapsulation you often want to make a private copy of the object.
发表评论
-
property “assign” and “retain” for delegate
2012-06-25 01:11 11761 Answer active oldest vo ... -
如何从一个方法中返回来自于集合的对象
2012-06-25 00:20 1082- (ImageScrollView *)dequeue ... -
类似Tweetie那种拽下来就refresh的代码
2012-06-22 12:28 851http://github.com/enormego/EGOT ... -
difference between frame and bounds Property
2012-06-17 21:55 1305bounds The bounds rectangle, wh ... -
Apple Offical : View Programming Guide for iOS
2012-06-16 17:06 1059https://developer.apple.com/lib ... -
use UINavigationController inside a UITabBarController
2012-06-16 13:39 1590If you want to add a UINavigati ... -
关于ios中bounds与frame
2012-06-16 12:03 19801.ios中的bounds是指相对于视图自己的坐标,所以默认v ... -
Enum常量放入NSArray的方法
2010-09-07 23:14 2515ypedef enum { UIViewAnim ... -
objective-c NSString 使用详细指南
2010-09-02 11:36 1948Declaring Constant String Obje ... -
What is Core Data?
2010-08-31 22:03 1372Path to Success The Core Data P ... -
Iphone开发常用软件
2010-07-19 16:41 885粒子特效:particleillusion -
iPhone にインストールされているフォント一覧
2010-07-19 13:21 1578タイトルの通り、iPhone にインストールされているフォン ... -
Cocoaのメモリ管理(3)
2010-07-15 14:42 746保持と解除という方法 ... -
The cocos2d Tips & Tricks
2010-07-02 14:32 1107The cocos2d Tips & Tricks i ...
相关推荐
- **Declared Properties:** Objective-C supports properties, which provide a convenient way to access instance variables. The document covers the type and functions associated with properties, ...
5. 属性(Declared Properties):属性提供了一种声明接口中变量的方式,并且提供了getter和setter方法。文档会介绍属性声明、属性声明属性、属性实现指令、使用属性、支持的类型、属性重声明、Core Foundation、...
4. 属性(Declared Properties) - 阐述了属性的声明和实现,属性声明的属性、属性声明的属性、以及属性实现的指令。 - 说明了如何使用属性、支持的类型以及属性的重声明。 - 涉及了与Core Foundation的子类化、...
•B254896 - dxZoomTrackBar - The "List capacity out of bounds" error occurs when setting Properties.Min/Properties.Max greater/less than 100 •Q468799 - In-place cxRichEdit - The width taken into ...
- **Property Declaration**: Properties are declared in the class interface using the `@property` keyword. For example, `@property (nonatomic, strong) NSString *name;`. - **Synthesizing Properties**: ...
Use the procedure GridDefaultDrawStyleEh, SetGridDefaultDrawStyleEh, declared in a module GridsEh.pas to access GridDrawStyle the object. TGridDrawStyleEh type has the following properties: ...
One of the core features of C# is its type safety, which ensures that variables can only hold values of the types they were declared to hold. This helps prevent runtime errors and makes the code more ...
- **Declared Accessibility**: Section 10.6.1 discusses declared accessibility of members. - **Name Lookup**: Section 10.7 covers name lookup rules in C++/CLI. #### Preprocessor (Chapter 11) - **...
确保"Declared SRS"选择正确,比如这里选择了"2010"。"Native Bounding Box"和"Lat/Lon Bounding Box"可以通过计算来自数据自动填充。 完成这些配置后,你可以在"Layers"列表中看到新添加的图层。点击"Layer ...
- **Inheritance**: How to create a hierarchy of classes by inheriting properties and behaviors from a superclass. - **Polymorphism**: Using interfaces and abstract classes to achieve polymorphism. - *...
Declaring class properties or methods as static makes them accessible without needing an instantiation of the class. A property declared as static cannot be accessed with an instantiated cla
For example, a car can be considered an object with properties (color, make, model) and behaviors (drive, stop). ##### 2. In Visual Basic .NET In VB.NET, objects are used extensively. They are the ...
Custom Exception inherits the properties from the Exception class. Whenever we have declare our own exceptions then we call it custom exceptions. Throwing an exception All methods use the throw ...
这可以通过在组件控制器 (`COMPONENT_CONTROLLER`) 和视图属性 (`View Properties`) 标签页中按下相应按钮完成。 #### ![图片示例] 此时,我们已经拥有一个 ALV 组件及其对应的控制器。 #### ![图片示例] ##### ...
<br>Declared datasources <br> <br>Application deployment 发布应用 <br> <br>Log file browser 日志文件浏览器 <br> <br>System information 系统信息 <br> <br>Connector ...
### SQLAlchemy:对象关系映射(ORM)详解 #### 概述 SQLAlchemy 是一个 Python 的 SQL 工具包和 ORM(对象关系映射),它提供了一种方式将自定义的 Python 类与数据库表关联起来,并将这些类的实例(对象)与其...
Here is how the properties of a function are assigned in make_function_table(pop_struct *pop): pop[0].function_table[0].arity = 2; pop[0].function_table[0].macro = FALSE; pop[0].function_...
Chapter 5Nested Classes and Interfacesdescribes how classes and interfaces can be declared inside other classes and interfaces, and the benefits that provides. Finally, Chapter 6Enumeration ...