小编Ale*_*kov的帖子

Swift 1.2和Swift 2.0中的字符串长度

在以前版本的Swift中,我有以下代码.

func myfunc(mystr: String) {
    if mystr.utf16Count >= 3 {
Run Code Online (Sandbox Code Playgroud)

随着最新版本的Swift 1.2,我现在收到以下错误.

'utf16Count' is unavailable: Take the count of a UTF-16 view instead, i.e. count(str.utf16)
Run Code Online (Sandbox Code Playgroud)

好的,所以我按如下方式更改了我的代码.

func myfunc(mystr: String) {
    if count(mystr.utf16) >= 3 {
Run Code Online (Sandbox Code Playgroud)

但这不起作用.我现在得到以下错误消息.

'(String.UTF16View) -> _' is not identical to 'Int16'
Run Code Online (Sandbox Code Playgroud)

使用Swift 1.2获取字符串长度的正确方法是什么?

string swift

32
推荐指数
4
解决办法
5万
查看次数

警告:由`useForm` 创建的实例未连接到任何表单元素

我有一个构建表单的应用程序,我想为表单设置默认值。我用过:const [form] = Form.useForm();。我的表单标签如下所示:

<Form form={form} name="basic" onFinish={onFinish} onFinishFailed={onFinishFailed}>
Run Code Online (Sandbox Code Playgroud)

我尝试设置默认值:

form.setFieldsValue({
  name: object.name,
});
Run Code Online (Sandbox Code Playgroud)

在这里我收到下一个警告: Warning: Instance created by `useForm` is not connect to any Form element. Forget to pass `form` prop?

我在这个主题上看到了很多答案,但他们通过添加form={form}. 在我的情况下它不起作用。可能是什么问题?

reactjs

6
推荐指数
4
解决办法
4212
查看次数

如何使用 FFMpeg 同时收听 2 个传入的 rtsp 流

我可以使用以下代码通过 FFMpeg 库收听和接收一个 rtsp 流:

AVFormatContext* format_context = NULL
char* url = "rtsp://example.com/in/1";
AVDictionary *options = NULL;
av_dict_set(&options, "rtsp_flags", "listen", 0);
av_dict_set(&options, "rtsp_transport", "tcp", 0);

int status = avformat_open_input(&format_context, url, NULL, &options);
av_dict_free(&options);
if( status >= 0 )
{
    status = avformat_find_stream_info( format_context, NULL);
    if( status >= 0 )
    {
        AVPacket av_packet;
        av_init_packet(&av_packet);

        for(;;)
        {                                                                      
            status = av_read_frame( format_context, &av_packet );
            if( status < 0 )
            {
                break;
            }
        }
    }
    avformat_close_input(&format_context);
}
Run Code Online (Sandbox Code Playgroud)

但是,如果我尝试同时打开另一个类似的侦听器(在另一个带有另一个 url 的线程中),我会收到错误消息:

无法打开 RTSP 进行侦听 rtsp://example.com/in/2:地址已在使用中 …

c ffmpeg rtsp

5
推荐指数
1
解决办法
3945
查看次数

标签 统计

c ×1

ffmpeg ×1

reactjs ×1

rtsp ×1

string ×1

swift ×1