在我安装Xcode 7 beta并将我的swift代码转换为Swift 2之后,我遇到了一些我无法弄清楚的代码问题.我知道Swift 2是新的,所以我搜索并弄清楚,因为没有任何关于它,我应该写一个问题.
这是错误:
调用可以抛出,但它没有标记为'try',并且没有处理错误
码:
func deleteAccountDetail(){
let entityDescription = NSEntityDescription.entityForName("AccountDetail", inManagedObjectContext: Context!)
let request = NSFetchRequest()
request.entity = entityDescription
//The Line Below is where i expect the error
let fetchedEntities = self.Context!.executeFetchRequest(request) as! [AccountDetail]
for entity in fetchedEntities {
self.Context!.deleteObject(entity)
}
do {
try self.Context!.save()
} catch _ {
}
}
Run Code Online (Sandbox Code Playgroud)
快照:

当用户使用swift 在UITextField中输入时,我想计算字符数.
字段和标签的图像:

我已经放置了UITextField和UILabel,只是没有找到有关Stack溢出的任何信息,如果你可以在UITextView中做一个我也很感激.
试图使Bootstrap显示工具提示功能,我完全按照关于工具提示的Bootstrap DOC并声明我的属性和属性.当我将鼠标悬停在文本上时,数据显示只有函数,但不是像文档中提到的Bootstrap样式.Some tooltip text!alt=""
我采取的步骤来解决此问题:
<Script>$('[data-toggle="tooltip"]').tooltip({'placement': 'top'});</script>标头HTML标记
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/style.css" rel="stylesheet">
<!-- Latest compiled and minified JavaScript -->
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
HTML标记
<a href="#" data-toggle="tooltip" title="Some tooltip text!">Hover over me</a>
Run Code Online (Sandbox Code Playgroud)
这是一个如何显示的图像.

我遇到了一个问题,我正试图在UIView边界内解决,有没有办法将相机预览添加到UIView?并在UIView(按钮,标签等)上添加其他内容?
我尝试使用AVFoundation Framework,但没有足够的Swift文档.
我按照本教程和/或Facebook SDK文档中的所有步骤在 我的应用程序上安装Facebook登录,但是当我运行代码时出现错误.虽然Facebook提到我可以使用import(Swift)来包含框架,但我尝试使用Objective-C Bridge Header来做旧时尚.
错误:
找不到'FBSDKLoginKit/FBSDKLoginKit.h'文件
屏幕截图
正如您所看到的,编译器正在读取bridge.h,但由于内部文件错误,它将引发错误.

Bridge.h
在Xcode 6中你不需要桥头文件,我可以这样做import
#import <FBSDKLoginKit/FBSDKLoginKit.h>
Run Code Online (Sandbox Code Playgroud)
这个问题是由Xcode 7 Beta引起的,我试图在Xcode 6上做到这一点,并且只与它完美配合import FBSDKLoginKit.任何人都可以告诉我这个黑客吗?或者如果有办法将我的Swift 2代码转换回1.4并使用Xcode 6.
大家好,标题提到我正试图用快速语言从我的Redis服务器发送和接收数据.我已经做了很多研究,我无法得到关于这个主题的好答案,我最接近的是NSStream或几个Github项目(其中大部分都有破碎的代码),我一直试图为3创建一个解决方案几天了,请有人帮忙.
端口6379上Redis的连接要求:
问题:
EXC_BAD_ACCESS(code=1, address=XXXXXXXX) SOMETIMES具有初始化的类(Redis): 最接近我可以达到我理解NSStream的过程的级别,但是再次在我的对话框中没有打印任何返回的内容,我无法弄清楚出了什么问题.
class Redis: NSObject, NSStreamDelegate {
//Intilizing Stream & Requirement
var endPoint: CFString?
var onPort: UInt32?
var inputStream: NSInputStream?
var outputStream: NSOutputStream?
Run Code Online (Sandbox Code Playgroud)
服务器连接功能:
func serverConnection(endPoint: CFString, onPort: UInt32){
//Streams Init
let Host: CFString = endPoint
let Port: UInt32 = onPort
var readStream: Unmanaged<CFReadStream>?
var writeStream: Unmanaged<CFWriteStream>?
//Bind Streams to Host and Port
CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, Host, Port, …Run Code Online (Sandbox Code Playgroud) 在us.json加载,但是当我尝试添加标签的名字我不能使它发挥作用.我没有在.json文件中看到name属性,所以如何添加每个州名?我是这个框架的新手.
我在Google和Stackoverflow上尝试了不同的教程,但它们都不适合我.这是我试过的情侣教程的链接,我认为值得.
我担心的问题:
http://d3js.org/topojson.v1.min.js?.html 文件(框架已加载)
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
.js 文件:
var width = 1500,
height = 1100,
centered;
var usData = ["json/us.json"];
var usDataText = ["json/us-states.json"];
var projection = d3.geo.albersUsa()
.scale(2000)
.translate([760, height / 2]);
var path = d3.geo.path()
.projection(projection);
var svg = d3.select("body").append("svg")
.style("width", "100%")
.style("height", "100%");
svg.append("rect")
.attr("class", "background")
.attr("width", width)
.attr("height", height)
.on("click", clicked);
var g = svg.append("g");
d3.json(usData, function(unitedState) {
g.append("g")
.attr("class", "states-bundle")
.selectAll("path") …Run Code Online (Sandbox Code Playgroud) 我已经创建了一个自定义AVFoundation摄像头并作为子视图加载到另一个视图中使用@IBDesignable,在拍摄图像后我想将其分配给UIImageView,但是当按下按钮时,自定义摄像头视图(UIView)会崩溃并向上移动屏幕,而不是将其分配给UIImageView,这发生在自定义摄像头视图加载开始时,然后当我再次加载自定义摄像头视图时,它会将图像分配给UIImageView.
捕获图像方法:
@IBAction func captureImage(sender: AnyObject) {
if let stillOutput = self.captureImageOutput {
// we do this on another thread so that we don't hang the UI
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
//find the video connection
var videoConnection : AVCaptureConnection?
for connecton in stillOutput.connections {
//find a matching input port
for port in connecton.inputPorts!{
if port.mediaType == AVMediaTypeVideo {
videoConnection = connecton as? AVCaptureConnection
break //for port
}
}
if …Run Code Online (Sandbox Code Playgroud) 为AVFoundation自定义图层相机创建精确的自动对焦和曝光的最佳方法是什么?例如,目前我的相机预览图层是方形的,我希望将相机焦点和曝光指定到该帧边界.如果可能的话,我需要在Swift 2中使用它,如果没有,请写下你的答案我可以自己转换它.
当前自动聚焦和曝光:但是正如您所看到的,这将在聚焦时评估整个视图.
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
//Get Touch Point
let Point = touches.first!.locationInView(self.capture)
//Assign Auto Focus and Auto Exposour
if let device = currentCameraInput {
do {
try! device.lockForConfiguration()
if device.focusPointOfInterestSupported{
//Add Focus on Point
device.focusPointOfInterest = Point
device.focusMode = AVCaptureFocusMode.AutoFocus
}
if device.exposurePointOfInterestSupported{
//Add Exposure on Point
device.exposurePointOfInterest = Point
device.exposureMode = AVCaptureExposureMode.AutoExpose
}
device.unlockForConfiguration()
}
}
}
Run Code Online (Sandbox Code Playgroud)
相机层: 1:1比例的任何内容都应被视为焦点和曝光点,此范围之外的任何内容甚至不会被视为相机焦点的触摸事件.
我对基础知识很熟悉,我想知道如何禁用该按钮,并且当用户输入验证时,它会更改按钮以启用提交.
表格示例:
<form data-abide>
<div class="name-field">
<label>Your name <small>required</small>
<input type="text" required pattern="[a-zA-Z]+">
</label>
<small class="error">Name is required and must be a string.</small>
</div>
<div class="email-field">
<label>Email <small>required</small>
<input type="email" required>
</label>
<small class="error">An email address is required.</small>
</div>
<input id="contactsubmit" class="button" type="submit" value="SEND" disabled>
</form>
Run Code Online (Sandbox Code Playgroud)
禁用:
<input id="contactsubmit" class="button" type="submit" value="SEND" disabled>
Run Code Online (Sandbox Code Playgroud)
现在,当用户继续输入时,我希望它被验证,如果一切正确启用按钮,我知道我可以用jQuery做到这一点.change(),但有没有任何标准的方法可以遵守?
我做了很多研究,但我没有看到我想要实现的目标,我可以通过bootstrap验证而不是基础来实现.
这是我用bootstrap实现我想要的插件,Validator.js.