Assign a bell tone to the contact according to the following steps:1. Click contacts on the standby screen ].2. Select group ].3. Select the specified group, and click and hold.4. Select edit Group ].5. Select [ringtone ].6. Select [ringtones ].7. Select the specified [ringtone ].8. Select confirm ].Note:You can only assign
Brief Introduction
We often see the assign,extend,merge function in someone else's code, which is similar to the three functions that merge the properties of the source object into the target object.
Since all are merging objects, why are there three different functions? What is the difference between them? assign (object, [sources])
Let's look at the definition on the official website first:
Assigns own e
Assign: Specifies the setter method with a simple assignment, which is the default action. You can use this property for scalar types, such as int. You can imagine a float, which is not an object, so it can't be retain, copy. Assign specifies the setter method with a simple assignment, which is the default action. You can use this property for scalar types, such as int. You can imagine a float, which is not
Assign: Simple assignment, not changing index countCopy: Create an object with an index count of 1 and then release the old objectRetain: Frees the old object, assigns the value of the old object to the input object, and then increases the index count of the input object to 1Copy actually creates an identical object, and retain is not:such as a NSString object, the address is 0x1111, the content is @ "STR"Copy to another nsstring, the address is 0x222
Assign: Simple assignment, not changing index countCopy: Create an object with an index count of 1 and then release the old objectRetain: Frees the old object, assigns the value of the old object to the input object, and then increases the index count of the input object to 1Copy actually creates an identical object, and retain is not:such as a NSString object, the address is 0x1111, the content is @ "STR"Copy to another nsstring, the address is 0x222
Meanings of keywords such as assign, copy, and retain in iOS
Assign: simple assignment without changing the index countCopy: Create an object with an index count of 1 and release the old object.Retain: Release the old object, assign the value of the old object to the input object, and increase the index count of the input object to 1.
Copy actually creates the sa
The Assign method is understood to be to empty the original string first and then assign a new value to replace it.Returns a reference of type string. Its common overloads are also available in the following ways:A. string assign (const string str);Replace Str with the contents of the original stringExample:String testassign = "Hello World";Testassign.assign ("Go
Source: http://www.2cto.com/kf/201205/133943.html
Assign: simple assignment without changing the index count
Copy: Create an object with an index count of 1 and release the old object.Retain: Release the old object, assign the value of the old object to the input object, and increase the index count of the input object to 1.
Copy actually creates the same object, and retain is not:
For example, an nsstring
A few days ago, I tried to make a very simple control (based on the D5 developer guide)This control uses a class inherited from tpersistent.
TypeTsomeobject = Class (tpersistent)PrivateFprop1: integer;Fprop2: string;PublicProcedure assign (Source: tpersistent); override;PublishedProperty prop1: integer read fprop1 write fprop1;Property prop2: String read fprop2 write fprop2;End;
....
Procedure tsomeobject. Assign
another nsstring, the address is 0x2222, the content is the same, the new object retain is 1, the old object has not changedRetain to another nsstring, the same address (set up a pointer, pointer copy), the content of course the same, the object's retain value +1That is, retain is a pointer copy and copy is a copy of the content. Wow, it's a lot easier than you think.The set method of retain should be shallow copy, copy's set method should be deep copyCopy another usage:Copy is a copy of the co
access to the property, the return value obtained from the picker, or the value set by the setting can be done at once, even if another thread is accessing it. If you do not specify nonatomic, the parsed accessor retains and automatically releases the returned value in the environment in which it manages the memory, and if nonatomic is specified, the accessor simply returns the value.AssignFor the underlying data type (nsinteger,cgfloat) and the C data type (int, float, double, char), and so on
of these problems are serious, so be sure to pay attention to memory release and set to nil after usemember variables and propertiesIt's not as simple as it is, you might need to call another function to assign a variable in one function.There are two options:class member variables and usage properties@interface Testmem:nsobject {Testobject *m_testobject; //Member variablesTestobject *testobject; //Member variables}The member variables are consistent
time passes?Why did such a thing happen? Let's take a look at the code inside the edit controller. Publicfunction edit () {if(Request (),IsPost ()) {//If the form is submitted $data= Input ("Post.");//Get data to the editing interface $validate= Loader::validate ("Link");//Load Validator classif(! $validateCheck ($data)) {//Verify data is consistent with our defined validation rules$ ThisError ($validate->geterror (),"Edit","","2"); Die } $linkModel =NewLinkmodel ();$updat
Copy: Create an object with an index count of 1 and release the nsstringIt indicates to nsstring that a copy of the input value is used when the value is assigned. The copy operation is executed by the copy method. This attribute is only valid for object types that implement the nscopying protocol. For more information, see "copy.
Retain: Release the old object, assign the value of the old object to the input object, and increase the index count of th
Copy: Create an object with an index count of 1 and release the nsstringIt indicates to nsstring that a copy of the input value is used when the value is assigned. The copy operation is executed by the copy method. This attribute is only valid for object types that implement the nscopying protocol. For more information, see "copy.
Retain: Release the old object, assign the value of the old object to the input object, and increase the index count of th
another nsstring, the address is 0x2222, the content is the same, the new object retain is 1, the old object has not changedRetain to another nsstring, the same address (set up a pointer, pointer copy), the content of course the same, the object's retain value +1That is, retain is a pointer copy and copy is a copy of the content. Wow, it's a lot easier than you think.The set method of retain should be shallow copy, copy's set method should be deep copyCopy another usage:Copy is a copy of the co
Assign: Simple assignment, not changing index countCopy: Create an object with an index count of 1 and then release the old objectRetain: Frees the old object, assigns the value of the old object to the input object, and then increases the index count of the input object to 1Copy actually creates an identical object, and retain is not:such as a NSString object, the address is 0x1111, the content is @ "STR"Copy to another nsstring, the address is 0x222
Assign: Simple assignment, not changing index countCopy: Create an object with an index count of 1 and then release the old objectRetain: Frees the old object, assigns the value of the old object to the input object, and then increases the index count of the input object to 1Copy actually creates an identical object, and retain is not:such as a NSString object, the address is 0x1111, the content is @ "STR"Copy to another nsstring, the address is 0x222
Assign: simple assignment without changing the index countCopy: Create an object with an index count of 1 and release the old object.Retain: Release the old object, assign the value of the old object to the input object, and increase the index count of the input object to 1.
Copy actually creates the same object, and retain is not:For example, an NSString object with the address 0 × 1111 and the content @ "
Use assign: for underlying data types (nsinteger,cgfloat) and C data types (int, float, double, char, and so on)Using copy: On NSStringUse retain: For other nsobject and its subclassesAssign: Simple assignment, not changing index countCopy: Create an object with an index count of 1 and then release the old objectRetain: Frees the old object, assigns the value of the old object to the input object, and then increases the index count of the input object
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.