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?

Thanks in advance.


_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to