Trying to create a connection of a request with an URL. An NSMutableData instance (responseData) also gets called with it. When the connection starts receiving response, the setLength:NSUInteger method gets called up on the NSMutableData Instance.
-(void)startDataDownloading
{
NSURLRequest *_request = [NSURLRequest requestWithURL:self.url];
if (_request) {
if (!connecton) {
connecton = [NSURLConnection connectionWithRequest:_request delegate:self];
if (connecton) {
responseData = [NSMutableData data];
[connecton start];
}
}
}
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
[responseData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[responseData appendData:data];
}
But somehow it causes a crash with a warning on the setLength call. The error states that
" -[__NSCFDictionary setLength:]: unrecognized selector sent to instance 0x6a8cf70 2012-11-30 18:00:38.948 RSSReader[8997:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setLength:]: unrecognized selector sent to instance 0x6a8cf70' "
Any hint about this would be appreciated.
#import <Foundation/Foundation.h>
#import "DataParser.h"
@protocol DataConnectionDelegate <NSObject>
//protocol methods
@end
@interface UCDataConnection : NSObject <ModelParser>
@property (nonatomic, strong) NSURL *url;
@property (nonatomic, strong) NSURLConnection *connecton;
@property (strong, nonatomic) NSMutableData *responseData;
@property (nonatomic, assign) id<DataConnectionDelegate> delegate;
-(void)startDataDownloading;
- (id)initWithUrl:(NSURL *)_url andDelegate:(id<DataConnectionDelegate>)_delegate;
That is a part of the header file.Sorry for late response.