从核心数据中获取所有这些数据,并且返回nil,这是我的代码
var user_id:String!
var customer_name:String!
var customer_phone:String!
var resturant_id:String!
var card_id:String!
var customer_coordinate:String!
var customer_address:String!
var address_id:String!
var card_idd:String!
let param: [String : AnyObject] = ["customer_id":user_id!, "customer_name":customer_name!,"customer_phone":customer_phone!,"total": 3223, "delivery_fee": 200, "restaurant_id": 5, "card_id": card_idd!,"customer_address_id": 20,"customer_street_address": customer_address!, "customer_address_coordinates": customer_coordinate!,"OrderDetails": vrt]
print(param)
但是param正在返回一个可选的
这里是如何从核心数据中获取数据
func fetchUserCheck(customer_coordinate:String,customer_name:String,customer_address:String,customer_phone:String){
let app = UIApplication.sharedApplication().delegate as! AppDelegate
let context = app.managedObjectContext
var users = [User]()
var fetchRequest = NSFetchRequest(entityName: "User")
do{
users = try context.executeFetchRequest(fetchRequest) as! [User]
for user in users{
user.longLat = customer_coordinate
user.address = customer_address
user.name = customer_name
user.phone = customer_phone
}
}catch{
print("")
}
}