是否可以在iPad中显示仅包含0-9数字的键盘?我不希望键盘显示任何其他内容.我知道我们可以在.xib文件中使用这个KeyboardType:Number Pad,但它会显示包括数字在内的所有其他额外字符.我想使用这个概念来显示我正在处理的iPad应用程序的PIN登录键盘.谢谢
对不起,如果我的问题不明确,我会尽量让自己明白解释.所以这正是我想要做的,我正在尝试使用Alamofire发布多个评论(我的应用程序实现的东西,并且每当用户编写新评论时都将存储为JSON对象).我将这些JSON注释传递给我的post例程,在那里我可以使用SwiftyJSON来提取每个值.Noe,我知道如何设置参数,如果我试图授权用户如下,
var parameters = [
"userName": userName,
"password": passwordSalt,
"somethingElse": somethingElse
]
var err: NSError?
request.HTTPBody = NSJSONSerialization.dataWithJSONObject(parameters , options: nil, error: &err)
Run Code Online (Sandbox Code Playgroud)
直到这里,这很简单,现在是我的问题.我正在尝试使用alamofire post发布多个json对象,这应该是这样的
[
{
"comment": "my First Comment",
"commentDate": "2014-05-13 14:30 PM",
"isSigned": 1,
"patientId": 2,
"documentId": 3
},
{
"comment": "my SecondComment",
"commentDate": "2014-05-14 14:30 PM",
"isSigned": 2,
"patientId": 3,
"documentId": 4
},
{
"comment": "my third Comment",
"commentDate": "2014-05-15 14:30 PM",
"isSigned": 3,
"patientId": 4,
"documentId": 5
}
]
Run Code Online (Sandbox Code Playgroud)
如何通过迭代JSON对象来创建上面的数组/ json(我不确定要调用它的内容)? …
我知道如何使用prepareForSegue函数中的segue传递数据,但是我有一个TableViewCell,它有两个可能的段到两个不同的ViewControllers(我们现在就说A,B).这里建议最好将segue连接到View控制器而不是tableCell本身,这实际上是完美的.但是我想在单击单元格时将信息传递给第二个View控制器,那么如何访问我连接到Source ViewController的segue.
码:
在prepareForSegue里面
if segue.identifier == "showQuestionnaire"{
if let indexPath = self.tableView.indexPathForSelectedRow() {
let controller = (segue.destinationViewController as! UINavigationController).topViewController as! QuestionnaireController
let patientQuestionnaire = patientQuestionnaires[indexPath.row] as! PatientQuestionnaire
controller.selectedQuestionnaire = patientQuestionnaire
self.performSegueWithIdentifier("showQuestionnaire", sender: self)
}
}
Run Code Online (Sandbox Code Playgroud)
再说一遍:这个问题不是关于通过prepareForSegue传递信息
我知道如何向alamofire请求添加自定义标头,但是可以在alamofire下载中添加自定义标头吗?另外,如何更改文件路径中保存的文件扩展名?
Alamofire.download(.GET, myURL, { (temporaryURL, response) in
if let directoryURL = NSFileManager.defaultManager()
.URLsForDirectory(.DocumentDirectory,
inDomains: .UserDomainMask)[0]
as? NSURL {
let pathComponent = response.suggestedFilename
return directoryURL.URLByAppendingPathComponent(pathComponent!)
}
return temporaryURL
}).response{ (_,_, data, err) -> Void in
println(data)
}
Run Code Online (Sandbox Code Playgroud)