在表视图中使用json值收集视图iOS swift throwing EXC_BAD_ACCESS

我正在尝试消费JSON值,并parsing获取EXC_BAD_ACCESSexception时parsing到表视图内的集合视图。 有人可以给我build议哪里出错了吗?

这是我的代码

我有一个名为RemoteAPI的类。 通过我打电话给http url和请求json数据

  class RemoteAPI { let url: NSURL = NSURL(string:"http://192.168.0.31:8097/api/asset/GetFile?username=username@gmail.com&RoleName=null&GroupName=null&EntityIdParam=1&StartIndex=1&EndIndex=300&PageIndex=0&PageSize=500&ItemsPerPage=1&Sort=0&EntityIdWithIndex=1&GName=null&GDesc=null&GId=null")! let ses = NSURLSession.sharedSession() let task = ses.dataTaskWithURL(url,completionHandler: {data, response, error -> Void in if (error != nil) { return completionHandler(nil, error) } var err: NSError? if(data != nil) { // let json = NSJSONSerialization.JSONObjectWithData(data, options:NSJSONReadingOptions.AllowFragments, error: &error) as NSDictionary var json = NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions.MutableContainers, error: &err) as NSDictionary if (err != nil) { println("JSON Error \(err!.localizedDescription)") } } }) task.resume() } } 

在viewDidLoad func我打电话给API

 override func viewDidLoad() { super.viewDidLoad() //self.loadData() api.getData({data, error -> Void in if (data != nil) { self.repositories = NSMutableArray(array: data) self.tableView!.reloadData() } else { println("api.getData failed") println(error) } }) } 

我声明了一个名为repositories的数组

  var repositories: NSMutableArray = [] 

在下面的表格视图cellForRowAtIndexPath方法中调用collection视图的datasource和delegate函数。

 override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as AssetTableViewCell // Configure the cell... let layout = UICollectionViewFlowLayout() layout.sectionInset = UIEdgeInsets(top: 20, left: 10, bottom: 10, right: 10) layout.itemSize = CGSize(width:50, height: 60) cell.collectionview.delegate = self cell.collectionview.dataSource = self cell.collectionview.tag = indexPath.row return cell } 

在集合视图cellForItemAtIndexPath我试图绑定parsing的JSON值

  func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { var cell = collectionView.dequeueReusableCellWithReuseIdentifier("CollectionViewCell", forIndexPath: indexPath) as? AssetCollectionViewCell if let navn = self.repositories[indexPath.row]["Name"] as? NSString { cell?.Assetname?.text = navn } else { cell?.Assetname?.text = "No Name" } if let desc = self.repositories[indexPath.row]["Description"] as? NSString { cell?.AssetDescription?.text = desc } return cell! } 

请给我一些build议,哪里出错了响应状态获得200我的服务,但我得到的数据超出scope.i注意到BAD_ACCESS错误是有关的内存pipe理,但我没有得到如何解决这个问题。

这是我的url数据包含

  [ { "$id":"1", "_Name":"Shared Assets", "_Description":"Shared Assets", "_rownum":"1", "_Id":"158", "_AppId_Fk":"15", "_EntityCode":"Shared Assets", "_EntityId":"0", "_EntityParentId":"1", "_CreatedDate":"11/25/2014 12:13:13 PM", "_ModifiedDate":"", "_Version":"1", "_LoginId":"ec2b3d5d-dcf0-452a-a735-fec16c287755", "_IsFolder":"True", "_FolderType":"1", "_EndIndex":" AS StartIndex,", "_OrderBy":"0", "_TotalNoOfPages":" AS CurrentPage,", "_IsGroup":" AS Sort,", "_SubName":"Shared Assets", "_pid":"158", "_NoOfAssets":"4", "_PageIndex":"1", "_TotalAssetPages":"1", "Name":"Shared Assets", "Description":"Shared Assets", "rownum":"1", "Id":"158", "AppId_Fk":"15", "EntityCode":"Shared Assets", "EntityId":"0", "EntityParentId":"1", "CreatedDate":"11/25/2014 12:13:13 PM", "ModifiedDate":"", "Version":"1", "LoginId":"ec2b3d5d-dcf0-452a-a735-fec16c287755", "IsFolder":"True", "FolderType":"1", "EndIndex":" AS StartIndex,", "OrderBy":"0", "TotalNoOfPages":" AS CurrentPage,", "IsGroup":" AS Sort,", "SubName":"Shared Assets", "pid":"158", "NoOfAssets":"4", "PageIndex":"1", "TotalAssetPages":"1", "Items":[ { "$id":"2", "_gname":"Shared Assets", "_gisfolder":"True", "_gdesc":"Shared Assets", "_gid":"158", "_FileSize":"", "_EntityId":"3785", "_Name":"Vicoast ", "_LoginId":"ec2b3d5d-dcf0-452a-a735-fec16c287755", "_EntityParentId":"0", "_Description":"Office docs", "_AName":"", "_FileType":"", "_SubName":"Vicoast ", "_ExpiryDate":"", "_AssetPath":"", "_IsFolder":"True", "_GDescription":"" } } ] 

有人请通过我的代码,告诉我我到底失去了什么?