I am doing JSON parsing in my App, When I Use responseData = [NSMutableData data]; it crashes on [responseData setLength:0];
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[responseData setLength:0]; // CRASH HERE
}
and when I use responseData=[[NSMutableData alloc]init]; my program works fine. I already make property in .h file
@property (strong, nonatomic) NSMutableData* responseData;
and synthesize in .m file
@synthesize responseData;
Question : what is difference between [NSMutableData data] and [[NSMutableData alloc]init];
thanks
[NSMutableData data]returns an autoreleased object whereas[[NSMutableData alloc] init]returns a retained object.