Ios EXC_坏访问(代码=2)-NSZombie没有给我任何东西

Ios EXC_坏访问(代码=2)-NSZombie没有给我任何东西,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我使用带有自定义单元格的UITableview来显示web服务中的列表。代码如下: #import "AgentEventsControllerViewController.h" #import "EventCell.h" @interface AgentEventsControllerViewController () { NSMutableData *webData; NSURLConnection *connection; NSMutableArray *myObject;

我使用带有自定义单元格的UITableview来显示web服务中的列表。代码如下:

#import "AgentEventsControllerViewController.h"
#import "EventCell.h"

@interface AgentEventsControllerViewController ()
{
  NSMutableData *webData;
  NSURLConnection *connection;
  NSMutableArray *myObject;
  // A dictionary object
  NSDictionary *dictionary;
  // Define keys
  NSString *EventID;
  NSString *Company;
  NSString *Summary;
}
@end

@implementation AgentEventsControllerViewController

- (id)initWithStyle:(UITableViewStyle)style
{
  self = [super initWithStyle:style];
  if (self) {
    // Custom initialization
  }
  return self;
}

- (void)viewDidLoad
{
  [super viewDidLoad];

  NSString *user = @"20";
  NSString *GetMe =@"JSON";
  NSString *urlString =[NSString stringWithFormat:@"http://MyService?user=%@&GetMe=%@",user,GetMe];


  NSURL *url = [NSURL URLWithString:urlString];

  NSURLRequest *request = [NSURLRequest requestWithURL:url];

  connection = [NSURLConnection connectionWithRequest:request delegate:self];

  if (connection)
  {
    webData = [[NSMutableData alloc]init];
  }


}

- (void)didReceiveMemoryWarning
{
  [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
  // Return the number of sections.
  return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
  // Return the number of rows in the section.
  return myObject.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  static NSString *CellIdentifier = @"EventCell";
  EventCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

  NSDictionary *tmpDict = [myObject objectAtIndex:indexPath.row];

  cell.EventID_lbl.text = [NSMutableString stringWithFormat:@"%@",
                           [tmpDict objectForKeyedSubscript:EventID]];
  cell.EventCompany_lbl.text = [NSMutableString stringWithFormat:@"%@",
                                [tmpDict objectForKeyedSubscript:Company]];
  cell.EventSummary_lbl.text = [NSMutableString stringWithFormat:@"%@",
                                [tmpDict objectForKeyedSubscript:Summary]];

  return cell;
}


- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
  [webData setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
  [webData appendData:data];
}

- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{

}

- (void) connectionDidFinishLoading:(NSURLConnection *)connection
{

  EventID = @"Event";
  Company = @"Company";
  Summary = @"Summary";

  myObject = [[NSMutableArray alloc] init];

  __autoreleasing NSError* error = nil;
  NSDictionary *result = [NSJSONSerialization JSONObjectWithData:webData options:kNilOptions error:&error];


  for (NSDictionary *item in result) {

    NSString *company_data = item[@"company"];
    NSString *summary_data = item[@"summary"];
    NSString *eventID_data = [NSString stringWithFormat:@"Event: %@", [item objectForKey:@"callref"]];

    dictionary = [NSDictionary dictionaryWithObjectsAndKeys:
                  eventID_data, EventID,
                  company_data, Company,
                  summary_data, Summary,
                  nil];
    [myObject addObject:dictionary];

  }


  [self.tableView reloadData];

}
一切似乎都很好,并将
tmpDict
打印到NSLog,我可以看到我期望的所有值,没有任何异常。但是,在加载过程中长时间暂停后,应用程序崩溃,EXC_BAD_访问代码=2。我已经启用了僵尸并在配置文件中运行,但当应用程序崩溃时,没有任何报告。据我所知,错误似乎发生在:

[self.tableView reloadData];
但是Xcode并没有透露是什么原因导致了它。我对Xcode非常陌生,所以我可能遗漏了一些显而易见的东西,但我看不出是什么


任何帮助,非常感谢。谢谢。

使用断点导航器在Objective-C异常上设置断点。当应用程序出现错误并进入调试器时,在调试控制台的(lldb)提示符处键入“bt”。这提供了一个堆栈跟踪,通常有助于指出问题。QuartzCore`CA::Layer::Sure_transaction_递归(CA::transaction*)+12,queue='com.apple.main thread',stop reason=EXC_BAD_ACCESS(代码=2,地址=0x7fff5f3ffff8)然后是一整堆的SECURE_transaction_递归行…无限循环?侧注:替换像
cell.EventID_lbl.text=[NSMUTABLETSTRING stringWithFormat:@“%@,[tmpDict ObjectForkeydSubscript:EventID]”这样的行带有
cell.EventID\u lbl.text=tmpDict[EventID]。不需要创建可变字符串。不需要使用
stringWithFormat
,并且使用现代字典语法。最后一件事-遵循标准命名约定。变量名应该是以小写字母开头的大小写。