0
Когда я запускаю свой проект, я получаю следующую ошибку: Thread 1: EXC_BAD_INSTRUCTION (код: EXC_I386_INVOP, subcode = 0x0. Я отправлю код ниже, но кто-нибудь знает, как это исправить?Тема 1: Ошибка EXC_BAD_INSTRUCTION при запуске проекта
появляется на тип ЛПЭ = PFUser.currentUser (!) [ "Type"], как? Строка
import UIKit
import Parse
import ParseUI
class TableViewController: PFQueryTableViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate {
var usersLocation: PFGeoPoint? {
didSet {
// This will reload the tableview when you set the users location.
// Handy if you want to keep updating it.z
if (tableView != nil) {
tableView.reloadData()
}
}
}
override func viewDidAppear(animated: Bool) {
}
override func viewDidLoad() {
super.viewDidLoad()
}
// Initialise the PFQueryTable tableview
override init(style: UITableViewStyle, className: String!) {
super.init(style: style, className: className)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
// Configure the PFQueryTableView
self.parseClassName = "User"
self.textKey = "fullName"
self.pullToRefreshEnabled = true
self.paginationEnabled = false
}
// Define the query that will provide the data for the table view
override func queryForTable() -> PFQuery{
let type = PFUser.currentUser()!["Type"] as? String
let age = PFUser.currentUser()!["Age"] as? String
let fitnessLevel = PFUser.currentUser()!["fitnessLevel"] as? String
var query = PFQuery(className:"User")
query.whereKey("Type", equalTo: type!)
query.whereKey("Age", equalTo: age!)
query.whereKey("fitnessLevel", equalTo: fitnessLevel!)
// If we don't have a location, just query without it.
if let geoLocation = usersLocation {
query.whereKey("geoLocation", nearGeoPoint:geoLocation)
}
query.limit = 100
return query
}
//override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("CustomCell") as! CustomCell!
if cell == nil {
cell = CustomCell(style: UITableViewCellStyle.Default, reuseIdentifier: "CustomCell")
}
// Extract values from the PFObject to display in the table cell
if let name = object?["fullName"] as? String {
cell.name.text = name
}
if let type = object?["lookingFor"] as? String {
cell.type.text = type
}
if let location = object?["location"] as? String {
cell.location.text = location
}
let cover = object?["cover"] as! PFFile
cover.getDataInBackgroundWithBlock {
(imageData: NSData?, error: NSError?) -> Void in
if error == nil {
if let imageData = imageData {
let image = UIImage(data:imageData)
}
}
}
let profile_pic = object?["profile_pic"] as! PFFile
profile_pic.getDataInBackgroundWithBlock {
(imageData: NSData?, error: NSError?) -> Void in
if error == nil {
if let imageData = imageData {
let image = UIImage(data:imageData)
}
}
}
return cell
}
}
привет спасибо вам помочь, но когда я это сделать это работает, но 3 строки ниже строк являются составной «неразрешенный идентификатор» – user4174219
Если пользователь ноль нет необходимости вообще выполнить запрос, я рекомендую проверить, является ли 'currentUser' нулем до того, как' queryForTable() 'вызван – vadian
Спасибо, что я использовал PFloginvieecontroller в начале для входа/выхода пользователя, но экран входа в систему не загружается из-за этой ошибки, поэтому я который, в свою очередь, вызывает эту ошибку. Вы знаете, как исправить это? – user4174219