Sunday, September 29, 2013

Variable with @ property (nonatomic, copy) defined, there is a need in the @ interface defined in it? Here defined variables defined with @ property change

Variable with @ property (nonatomic, copy) defined, there is a need in the @ interface defined in it?

@ Interface MapLocationInfo: UIViewController
{
NSString * lat ;/ / Longitude variable with @ property (nonatomic, copy) is defined, there is a need in the @ interface defined in it? Here defined variables defined variable with @ property What is the difference?

}

@ Property (nonatomic, copy) NSString * lat ;/ / Longitude


@ End
Reply:
Should be defined in the @ interface, interface is defined in the class members, and @ property (nonatomic, copy) NSString * lat ;/ / longitude, this is an indication of this property (nonatomic non-atomic order represents the current object is a thread running, so you can save resources; copy indicates that the property will automatically copy assignment object), and @ synthesize paired lets the compiler automatically generates a similar java in the get and set methods.
Reply:
@ Interface MapLocationInfo: UIViewController
{
/ / Define variables
}
/ / Define methods

@ End

Exactly two things.
Reply:
This issue will be IOS SDK5 get a good solution, in IOS SDK5, variables can be defined only in the @ property, and add a new property, strong.
ARC also provides support for IOS SDK5, later wrote OC procedures do not worry about the memory problem.

But if you are still in use SDK4 or earlier, then it must be stated in the Interface.

(Note: Although Apple has now provided SDK5 the download, but currently does not support APPStore submit applications based SDK5 )
Reply:
If the two are the same name of the place, it is not necessary, if not the same, it would need to have to write two outside.
Reply:
Affirmed only in the property when you use self.lat call

No comments:

Post a Comment