【问题标题】:Getting Error LIke:malloc: *** error for object 0xa2b6f50: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug得到错误 Like:malloc: *** 对象 0xa2b6f50 的错误:未分配被释放的指针 *** 在 malloc_error_break 中设置断点以进行调试
【发布时间】:2013-02-19 11:13:44
【问题描述】:

我正在使用启用了 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];
      }

感谢任何帮助。

【问题讨论】:

    标签: ios6 malloc breakpoints


    【解决方案1】:

    只需禁用添加此代码的文件 ARC。一开始试试... 并为此使用这个问题的答案How can I disable ARC for a single file in a project?

    【讨论】:

      猜你喜欢
      • 2014-05-14
      • 1970-01-01
      • 1970-01-01
      • 2018-07-29
      • 2023-03-29
      • 1970-01-01
      • 2013-10-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多