升级到swift 2.2和xcode 7.3后,我的应用程序崩溃,创建了服务客户端的实例。我在下面描述的客户:
ApiClient.swift
class ApiClient {
var clubsService: ClubsService
var eventsService: EventsService
var friendsService: FriendsService
var mainService: MainService
var mediaItemsService: MediaItemsService
var partiesService: PartiesService
var usersService: UsersService
init() {
clubsService = ClubsService()
eventsService = EventsService()
friendsService = FriendsService()
mainService = MainService()
mediaItemsService = MediaItemsService()
partiesService = PartiesService()
usersService = UsersService()
}
}
在EXC_BAD_ACCESS错误下,应用程序崩溃,在视图控制器内部客户端实例的声明中尝试声明客户端的一个实例能够使用服务。下面我描述了viewcontroller和错误点:
class MainViewController: UIViewController, UITableViewDataSource {
@IBOutlet weak var tableView: UITableView!
let apiClient = ApiClient() <-- EXC_BAD_ACCESS code = 2 <--
var flyers: [Flyer]!
var events: [Event]!
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
print("MainController viewWillAppear")
apiClient.mainService.List() { flyers, error in
if flyers != nil {
self.flyers = flyers
self.tableView.reloadData()
self.actInd.stopAnimating()
} else {
print("error: \(error)")
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.flyers?.count ?? 0
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) ->UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("mainObjectCell") as! MainTableViewCell
cell.mainObject = self.flyers?[indexPath.row]
return cell
}
}
}
在升级之前,应用程序有效,但现在却没有。 如果我直接从viewcontroller调用该服务,该应用程序可以工作,但我想维护客户端。 我正在尝试NSZombies,但我什么也没看到