• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Curious about a property being declared in the .h and the .m file for iOS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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: Ken Thomases <email@hidden>
  • Date: Mon, 15 Jul 2013 13:41:54 -0500

On Jul 15, 2013, at 1:31 PM, Alex Zavatone wrote:

> I'm looking at the wonderful examples here:
>
> http://www.objc.io/issue-2/common-background-practices.html
>
> And the particular file from the Asynchronous Networking section here:
>
> https://github.com/objcio/issue-2-background-networking
>
> Since I work in Xcode 4.2 often due to Snow Leopard, I wanted to make sure that everything was properly @synthesized and am confused about how to properly @synthesize the two NSError properties.  One is in the DownloadOperation.h file and the other in the DownloadOperation.m file.
>
> 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;
>
>
> Later on down in the .m file is the only place where error is used:
>
> - (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
> {
>    self.error = error;
>    self.isExecuting = NO;
>    self.isFinished = YES;
> }
>
>
> This appears not to be the cleanest way of doing this, but the compiler is obviously able to create the accessors.  The easy approach is to rename one of the properties given that both are the same name, but what would be the proper way to @synthesize both - if there is one?

That's not two properties, that's one property.  It's declared publicly read-only and redeclared privately read-write (in a class extension).

Regards,
Ken


_______________________________________________

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


References: 
 >Curious about a property being declared in the .h and the .m file for iOS (From: Alex Zavatone <email@hidden>)

  • Prev by Date: Re: Curious about a property being declared in the .h and the .m file for iOS
  • Next by Date: Re: Converting RTFD to Word with embedded images
  • Previous by thread: Re: Curious about a property being declared in the .h and the .m file for iOS
  • Next by thread: Unrecognized selector -[UIFont fontName]?
  • Index(es):
    • Date
    • Thread