Curious about a property being declared in the .h and the .m file for iOS
Curious about a property being declared in the .h and the .m file for iOS
- Subject: Curious about a property being declared in the .h and the .m file for iOS
- From: Alex Zavatone <email@hidden>
- Date: Mon, 15 Jul 2013 14:31:25 -0400
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@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