Re: Curious about a property being declared in the .h and the .m file for iOS
Re: Curious about a property being declared in the .h and the .m file for iOS
- Subject: Re: Curious about a property being declared in the .h and the .m file for iOS
- From: Uli Kusterer <email@hidden>
- Date: Mon, 15 Jul 2013 20:38:56 +0200
On Jul 15, 2013, at 8:31 PM, Alex Zavatone <email@hidden> wrote:
> DownloadOperation.h
> @interface DownloadOperation : NSOperation
> - (id)initWithURL:(NSURL*)url;
> @property (nonatomic, readonly) NSError *error;
>
> DownloadOperation.m
> #import "DownloadOperation.h"
>
> @interface DownloadOperation () <NSURLConnectionDelegate>
> @property (nonatomic, strong) NSURL* url;
> @property (nonatomic, strong) NSURLConnection* connection;
> @property (nonatomic, strong) NSMutableData *buffer;
> @property (nonatomic) long long int expectedContentLength;
> @property (nonatomic, readwrite) NSError *error;
That's not 2 properties, that is one being declared twice, once for external users (in the header) and once for internal use by the class. External users are only supposed to read the property, while the class itself of course has to be able to actually store a value in it, so it redeclares it from readonly to readwrite in a class continuation. This is pretty much the only valid way to declare the same property twice, changing anything else on the property will give an error message, but readonly -> readwrite is OK.
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden