我正在尝试在Swift/Xcode6中使用UITextFieldDelegate,我正在努力使用我应该使用stringByReplacingCharactersInRange的方式.编译器错误是'无法将表达式的类型'String'转换为'$ T8'类型.
func textField(textField: UITextField!, shouldChangeCharactersInRange range: NSRange, replacementString string: String!) -> Bool
{
let s = textField.text.stringByReplacingCharactersInRange(range:range, withString:string)
if countElements(s) > 0 {
} else {
}
return true
}
Run Code Online (Sandbox Code Playgroud)
Xcode 6 Beta 5的更新:问题是theChangeCharactersInRange给出了一个NSRange对象,我们需要一个用于stringByReplacingCharactersInRange的Swift Range对象.这仍然可以被认为是一个错误,因为我不明白为什么我们仍然应该处理NS*对象?委托方法的String参数无论如何都是Swift类型.
我在终端中有一个可用的 GStreamer-1.0 管道,我试图在 Mac/Xcode 上使用 GStreamer 1.0 在代码中复制它。
我的发送管道:
gst-launch-1.0 videotestsrc ! videoconvert ! x264enc ! rtph264pay config-interval=1 ! udpsink host=127.0.0.1 port=5000
Run Code Online (Sandbox Code Playgroud)
我的接收管道:
gst-launch-1.0 -vvv udpsrc port=5000 caps="application/x-rtp" ! rtph264depay ! avdec_h264 ! videoconvert ! xvimagesink
Run Code Online (Sandbox Code Playgroud)
这也可以通过以下 SDP 文件在 VLC 中播放:
v=0
m=video 5000 RTP/AVP 96
c=IN IP4 127.0.0.1
a=rtpmap:96 H264/90000
Run Code Online (Sandbox Code Playgroud)
我创建了以下代码来复制上述代码,但问题是接收管道在运行此代码时不显示任何内容。该代码确实根据 Xcode 调试控制台将数据包发送到网络。
gint
main (gint argc,
gchar *argv[])
{
GstElement *pipeline, *videosrc, *conv,*enc, *pay, *udp;
// init GStreamer
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
// setup …Run Code Online (Sandbox Code Playgroud) 请考虑以下片段着色器.当我在模拟器或iPhone 5(8.3)上运行时,它会显示预期的颜色(红色).如果我在iPhone 6 Plus(8.2)上运行它会转到第二个if子句(绿色),这显然是错误的,因为正确的计算结果应该在1.22左右.如果我直接将atan参数作为编译时常量提供,则计算有效.
我已经尝试了最新的Xcode 6.2和最新的6.3 Beta.
void main()
{
highp float y = 0.57;
highp float x = 0.21;
highp float a = atan(y, x);
// works if changed to atan(0.57, 0.21);
// does not work if changed to atan(y / x);
if (a > 1.2 && a < 1.25)
{
// Should always come here
// Works on Simulator, iPhone 5
gl_FragColor = vec4(1, 0, 0, 1);
}
else if (a > 1.5 && a < 1.55)
{ …Run Code Online (Sandbox Code Playgroud)