我正在使用启用了ARC的xcode 4.6。我想将一些图像添加到服务器的UItableview行。 我收到的错误如下:
malloc: *对象0xa2b6f50的错误:未分配被释放的指针 * 在malloc_error_break中设置断点以进行调试
这是我的代码:
NSURL * imageURL = [NSURL URLWithString:[templateURL stringByAppendingFormat:@“%@”,[[templateArray objectAtIndex:i] objectForKey:@“options_picture”]]];
UIImageView *templateView=[[UIImageView alloc]initWithFrame:CGRectMake(x1, y1, wid, ht)];
NSLog(@"templeteArray %@",imageURL);
AsyncronousUIImage *image=[[AsyncronousUIImage alloc]init];
[image loadImageFromURL:imageURL inImageView:templateView];
image.delegate=self;
[templateScroll addSubview:templateView];
AsyncronousUIImage类如下:
- (void)loadImageFromURL:(NSURL *)anUrl inImageView:(UIImageView*)imgView{
imageView = imgView;
NSURLRequest *request = [NSURLRequest requestWithURL:anUrl
cachePolicy:NSURLRequestReturnCacheDataElseLoad
timeoutInterval:30.0];
connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];}
- (void)connection:(NSURLConnection *)theConnection didReceiveData:(NSData *)incrementalData {
if (data == nil)
data = [[NSMutableData alloc] initWithCapacity:2048];
[data appendData:incrementalData];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)theConnection
{
[self initWithData:data];
data = nil;
connection = nil;
[self.delegate imageDidLoad:self];
}
感谢任何帮助。
答案 0 :(得分:3)
只需禁用添加此代码的文件ARC即可。先尝试一下...... 为此目的,请使用此问题的答案How can I disable ARC for a single file in a project?