小编sky*_*erl的帖子

Python [Errno 98]地址已在使用中

在我的Python套接字程序中,我有时需要用它来中断它Ctrl-C.当我这样做时,它会使用关闭连接socket.close().

但是,当我尝试重新打开它时,我必须等待一段时间才能再次连接.如何正确关闭套接字?或者这是打算?

python sockets connection errno

80
推荐指数
8
解决办法
11万
查看次数

在UITableView处于编辑模式时选择行

我有一个UITableView,当我把它放在编辑模式时,我希望选择行可选,但是,它们不是.有没有办法可以强迫他们选择?

iphone select row uitableview ios

52
推荐指数
1
解决办法
2万
查看次数

从兄弟目录导入

我有一个名为"ClassA"的Python类和另一个应该导入ClassA的Python类,它是"ClassB".目录结构如下:

MainDir
../Dir
..../DirA/ClassA
..../DirB/ClassB
Run Code Online (Sandbox Code Playgroud)

我如何使用sys.path以便ClassB可以使用ClassA?

python directory path parent sys

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

发送到解除分配的实例

每当我将视图控制器推到我的堆栈上,然后将其弹出,我收到此错误:

*** -[CALayer retainCount]: message sent to deallocated instance <memory address>
Run Code Online (Sandbox Code Playgroud)

它似乎发生在dealloc正在弹出的视图控制器上调用之后,并且仅对此视图控制器是独占的.我确定CALayer与视图本身有关,因为我不使用它们.

有任何想法吗?

编辑:这是回溯

(gdb) bt
#0  0x01fcd3a7 in ___forwarding___ ()
#1  0x01fa96c2 in __forwarding_prep_0___ ()
#2  0x01fc10e8 in CFGetRetainCount ()
#3  0x01cbc770 in CA::release_root_if_unused ()
#4  0x01cbc707 in x_hash_table_remove_if ()
#5  0x01cbc4ec in CA::Transaction::commit ()
#6  0x01cc4838 in CA::Transaction::observer_callback ()
#7  0x01fa5252 in __CFRunLoopDoObservers ()
#8  0x01fa465f in CFRunLoopRunSpecific ()
#9  0x01fa3c48 in CFRunLoopRunInMode ()
#10 0x027dd615 in GSEventRunModal ()
#11 0x027dd6da in GSEventRun ()
#12 0x0057cfaf …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c calayer retain

18
推荐指数
3
解决办法
7621
查看次数

"试图弹出一个不存在的视图控制器."

当我调用我的方法dismissView时,我收到此错误.这是方法存根:

-(IBAction)dismissView
{
    RootViewController *rootController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
    [self.navigationController popToViewController:rootController animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

这应该工作,我已经检查过,rootController被初始化和分配.有任何想法吗?

iphone objective-c uiviewcontroller uinavigationcontroller

13
推荐指数
5
解决办法
2万
查看次数

将NSDate与[NSDate日期]进行比较

我试图强制用户使用日期选择器选择将来的日期.我显然使用了compare:方法,但是,当我执行以下代码时,即使它与[NSDate date]的日期相同,它也会告诉执行if语句.这是我的代码:

    if ([datePicker.date compare:[NSDate date]] == NSOrderedAscending) // If the picked date is earlier than today
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hmm, this date is earlier than today" 
                                                    message:@"The date you've selected is earlier than today's date, please pick another" 
                                                   delegate:nil  
                                          cancelButtonTitle:@"Okay, I'll pick another" 
                                          otherButtonTitles:nil];
    // Show the alert
    [alert show];

    // Release the alert
    [alert release];
}
Run Code Online (Sandbox Code Playgroud)

iphone compare datepicker nsdate uidatepicker

11
推荐指数
2
解决办法
3万
查看次数

使用 URLSearchParams 防止百分比编码

我正在尝试使用 Node URL 和 URLSearchParams API 来使 URL 构建更简单一些。我用它来构建一个像这样的 URL:

https://<ye olde oauth host>/oauth/authorize?response_type=code&client_id=<my client id>&redirect_uri=https://localhost:4200&scopes=scope1%20scope2
Run Code Online (Sandbox Code Playgroud)

但是,我下面的代码创建的 URL 如下所示:

https://<ye olde oauth host>/oauth/authorize?response_type=code&client_id=<my client id>&redirect_uri=https%3A%2F%2Flocalhost%3A4200&scopes=scope1%20scope2
Run Code Online (Sandbox Code Playgroud)

据我了解,URLSearchParams API 将对字符串进行百分比编码,但如果我不希望对它们进行编码(例如 URL)怎么办?这是我的代码:

const loginURL = new URL('https://<ye olde oauth host>');
    url.pathname = 'oauth/authorize';
    url.search = new URLSearchParams({
      response_type: 'code',
      client_id: '<my client id>'
    }).toString();
loginURL.searchParams.append('redirect_uri', redirectURI);
loginURL.searchParams.append('scopes', scopes);
Run Code Online (Sandbox Code Playgroud)

我不希望对它redirect_uri进行百分比编码的原因是接收端的 OAuth API 不知道如何解析它。有什么方法可以使用 URLSearchParams 来阻止它编码吗?

javascript oauth node.js typescript angular

11
推荐指数
1
解决办法
7461
查看次数

将UITouch位置与UIImageView矩形进行比较

我有以下代码来确定触摸是否在我的表格单元格的图像视图中.但是,它不起作用.我将这两者与CGRectContainsPoint进行了比较,但它不起作用.这是代码:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event    
{
     // Declare the touch and get it's location

     UITouch *touch = [touches anyObject];

     CGPoint touchLocation = [touch locationInView:self];

     if (CGRectContainsPoint(myImageView.frame, touchLocation))
     {
        NSLog(@"Tapped image view");
     }    
}
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助!

iphone cocoa-touch objective-c uikit uitouch

6
推荐指数
1
解决办法
1万
查看次数

Check OS version using Swift on Mac OS X

I'm building an application that needs to check what version of OS X is installed on a Mac. It is built against 10.9 Mavericks, but all of the Swift APIs are pretty much 10.10 only.

I'm trying to use the following, however it does not compile against the 10.9 SDK since it does not have these APIs, I know how to use if #available(OSX 10.10, *) to conditionally compile as per the different versions, however because NSProcessInfo is a 10.10+ …

macos cocoa osx-mavericks swift osx-elcapitan

6
推荐指数
1
解决办法
3168
查看次数

使用SqlCommand.Parameters的C#更新表

我正在尝试使用SqlCommand更新MSSQL表,我认为这是我的T-SQL的语法错误,但是到目前为止,这是我所拥有的:

SqlCommand sqlCmd = new SqlCommand("UPDATE yak_tickets SET email = @emailParam, subject = @subjectParam, text = @textParam, statusid = @statusIDParam, ticketClass = @ticketClassParam WHERE id = @ticketIDParam", sqlConn);
Run Code Online (Sandbox Code Playgroud)

参数正在按应有的方式工作,但是,当我运行代码时,表永远不会更新。任何帮助将不胜感激=)

这是其余的代码:

    #region Parameters
    /* Parameters */
    sqlCmd.Parameters.Add("@ticketIDParam", SqlDbType.BigInt);
    sqlCmd.Parameters["@ticketIDParam"].Value = ticketID;

    sqlCmd.Parameters.Add("@emailParam", SqlDbType.NVarChar);
    sqlCmd.Parameters["@emailParam"].Value = ticketToBeSubmitted.getEmail();

    sqlCmd.Parameters.Add("@subjectParam", SqlDbType.NVarChar);
    sqlCmd.Parameters["@subjectParam"].Value = ticketToBeSubmitted.getSubject();

    sqlCmd.Parameters.Add("@textParam", SqlDbType.Text);
    sqlCmd.Parameters["@textParam"].Value = ticketToBeSubmitted.getTicketContent();

    sqlCmd.Parameters.Add("@statusIDParam", SqlDbType.NVarChar);
    sqlCmd.Parameters["@statusIDParam"].Value = ticketToBeSubmitted.getStatus();

    sqlCmd.Parameters.Add("@ticketClassParam", SqlDbType.NVarChar);
    sqlCmd.Parameters["@ticketClassParam"].Value = ticketToBeSubmitted.getTicketClass();
    #endregion

    #region Try/Catch/Finally
    /* Try/Catch/Finally */

    try
    {
        sqlConn.Open();
        sqlCmd.ExecuteNonQuery();
    }
    catch (SqlException sqlEx)
    { …
Run Code Online (Sandbox Code Playgroud)

c# sql sqlcommand sqlclient

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