我有这个代码将String转换为日期对象
let date2 = KeysData[indexPath.row]["starttime"] as? String
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
if let date = dateFormatter.dateFromString(date2!) {
println(date)
}
Run Code Online (Sandbox Code Playgroud)
我想知道如果当前日期落在2天我的阵列中得到之间startdate和endate
func loadViewFromNib() -> UIView {
let bundle = NSBundle(forClass: self.dynamicType)
let nib = UINib(nibName: "JobsView", bundle: bundle)
let view = nib.instantiateWithOwner(self, options: nil)[0] as! UIView
return view
}
Run Code Online (Sandbox Code Playgroud)
我试图加载我的JobsView.xib文件.但是,如果没有更多信息,它会给我带来不良访问.我该如何解决这个错误?
我已经从File的所有者链接了这个类
我有这个代码
User.findOne({ email: req.body.email }, function(err, user) {
if (user) {
return res.status(400).json([{ msg: 'The email address you have entered is already associated with another account.' }]);
}
user = new User({
name: req.body.name,
email: req.body.email,
password: req.body.password,
mobile: req.body.mobile
});
user.save(function(err) {
res.json({ token: generateToken(user), user: user });
});
});
Run Code Online (Sandbox Code Playgroud)
我尝试用邮递员发送请求,我确实得到了用户对象的回复,这意味着保存功能中没有错误
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJleGNlcHRpb25zLnNnIiwic3ViIjoiNTc5NWQ0NzQxYmEzZWQwODE1ZTgzY2NmIiwiaWF0IjoxNDY5NDM3MDQ0LCJleHAiOjE0NzAwNDE4NDR9.2otkcPkJgsXvR8QOHAojDJ5YCxR7Uc2E4ApS77T55F8",
"user": {
"__v": 0,
"created_at": "2016-07-25T08:57:24.612Z",
"updated_at": "2016-07-25T08:57:24.612Z",
"name": "Test",
"email": "Test@hotmail.com",
"password": "$2a$10$3UmABiDPeo6iHZ.DFbwOO.1ANpUWQmwr86bYbTmRuFedsbDcE0bbC",
"mobile": 12345,
"_id": "5795d4741ba3ed0815e83ccf"
}
}
Run Code Online (Sandbox Code Playgroud)
但是我的数据库中没有这个条目.我用Robomongo检查了我的数据库,我确信没有数据.我错过了什么?
我在这里有这个代码
let fundsreceived = String(stringInterpolationSegment: self.campaign?["CurrentFunds"]!)
cell.FundsReceivedLabel.text = "$\(funds received)"
Run Code Online (Sandbox Code Playgroud)
它正在打印出来 Optional(1000)
我已经添加!到变量但是可选项不会消失.知道我在这里做错了什么吗?