小编Mar*_*vec的帖子

在Objective-C中返回float数组

我想知道如何在方法中返回float数组.

在以下方法中:

- (float *) ......{
    float * result = malloc(sizeof(float) * number);
    ....
    return result;
}
Run Code Online (Sandbox Code Playgroud)

我的问题是我没有清理结果浮点数组.我怎样才能做到这一点?

arrays floating-point memory-management ios

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

核心数据总和性能

我有一些关于Core Data 和 sum函数的理论问题要问。

我尝试用三种方式对Core Data表中的值求和。

  1. 获取所有内容并使用表达式对其进行总结:

    NSArray * array1 = [self getAll:self.managedObjectContext];
    int sum = [[array1 valueForKeyPath:@"@sum.sum"] intValue];
    
    Run Code Online (Sandbox Code Playgroud)
  2. 获取所有并使用 for 循环:

    int sum2 = 0;
    NSArray * array2 = [self getAll:self.managedObjectContext];
    
    for (Test * t in array2) {
        sum2 = sum2 + [t.sum intValue];
    }
    
    Run Code Online (Sandbox Code Playgroud)
  3. 让 Core Data 总结一下。

    NSArray * array = [self getAllGroupe:self.managedObjectContext];
    NSDictionary * i = [array objectAtIndex:0];
    id j = [i objectForKey:@"sum"];
    
    (NSArray *)getAllGroupe:(NSManagedObjectContext*)Context{
    
        NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
        NSEntityDescription …
    Run Code Online (Sandbox Code Playgroud)

performance xcode sum core-data ios

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

UITableView 调整大小并在旋转时自动布局

我有一些奇怪的错误,我找不到解决方案。

我有使用自动布局的 UITableView。(在所有 4 个边上对齐到父级)。如果我旋转设备,它会正确呈现,但是如果我尝试滚动它,它会在屏幕左侧单独滚动。

在此处输入图片说明

红色方块是滚动区域。

我认为与此相关的下一个问题是当我尝试将 UIView 作为子视图添加到 UITableView 时。

如果我添加:

CGRect frame = CGRectMake(0, 200, self.table.frame.size.width, 5);
UIView * mainView = [[UIView alloc]initWithFrame:frame];
mainView.backgroundColor = [UIColor redColor];
[self.table addSubview:mainView];
Run Code Online (Sandbox Code Playgroud)

没关系,但如果我喜欢:

UIView * mainView = [[UIView alloc]init];
mainView.backgroundColor = [UIColor redColor];
mainView.translatesAutoresizingMaskIntoConstraints = NO;
[self.table addSubview:mainView];

[self.table addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-(200)-[mainView(20)]" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(_table, mainView)]];

[self.table addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[mainView]|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(_table, mainView)]];
Run Code Online (Sandbox Code Playgroud)

得到 na 错误:

*** Assertion failure in -[UITableView layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2903.23/UIView.m:8540
Run Code Online (Sandbox Code Playgroud)

rotation uitableview ios autolayout

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

故事板中使用的UIView的自定义属性

我知道可以做到,但是我不记得怎么做。

我想创建视图的一些属性,并能够在界面构建器中更改它。另外,我希望在指定UIView的类后,在界面生成器中正确呈现此视图。

有人能帮我吗

xcode interface-builder swift swift2

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

在 SFSafariViewController 中设置请求授权标头

我有一个具有用户名和密码的应用程序,以便用户登录到该应用程序。一些(不太重要的)功能仍然是网页。

但为了用户友好,用户已经登录后再次登录很烦人。

我正在查看 SFSafariViewController,它看起来很有前途,但我试图在调用 URL 时设置授权标头。我已经知道用户令牌,但需要将其设置为授权标头。

所以流程是:

User log in inside App -> get token -> set this token as Authorization header -> call my web app url
Run Code Online (Sandbox Code Playgroud)

这个控制器可以实现吗?

token request-headers jwt sfsafariviewcontroller

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

卷曲 SSL 证书

我在 ubuntu 服务器上下载 docker 时遇到问题。

\n\n

如果我输入:

\n\n
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -\n
Run Code Online (Sandbox Code Playgroud)\n\n

我得到:

\n\n
curl: (60) SSL certificate problem: unable to get local issuer certificate\nMore details here: https://curl.haxx.se/docs/sslcerts.html\n\ncurl failed to verify the legitimacy of the server and therefore could not\nestablish a secure connection to it. To learn more about this situation and\nhow to fix it, please visit the web page mentioned above.\n
Run Code Online (Sandbox Code Playgroud)\n\n

我用谷歌搜索并尝试了几种想法,例如:

\n\n
sudo apt install apt-transport-https ca-certificates curl software-properties-common\n\nsudo apt-get install ca-certificates\n …
Run Code Online (Sandbox Code Playgroud)

ubuntu curl certificate docker

5
推荐指数
0
解决办法
3181
查看次数

每个请求更改log4j中的优先级

我是Logging和Log4j的新手.我想要做的是更改每个请求的记录器级别.这意味着:

通常,优先级设置为ERROR,但用户可以使用特殊参数调用服务器,以将优先级日志级别设置为DEBUG,但仅限于该用户/请求.

这意味着如果用户A发送请求http://myServer.com/test,则仅记录优先级为ERROR的消息.

但是,如果用户A发送请求http://myServer.com/test?debug=true,则记录器会记录所有消息,但是如果用户B同时发送请求http://myServer.com/test,则仅记录ERROR消息.

如果这些日志可以保存在新的appender中,那就太好了.

logging log4j request

4
推荐指数
1
解决办法
594
查看次数

Apple证书无效,PKCS7_verify

我下载了AppleRootCertificate.cer,现在我尝试检查我的应用程序内收据证书是否有效(与苹果一样).

我喜欢他的WWDS视频中的苹果.

    BIO *b_receipt = BIO_new_mem_buf((void *)[receipt bytes], (long)[receipt length]);
    BIO *b_x509 = BIO_new_mem_buf((void *)[certificateData bytes], (long)[certificateData length]);

    // Convert receipt data to PKCS #7 Representation
    PKCS7 * p7 = d2i_PKCS7_bio(b_receipt, NULL);

    // Create the certificate store for matching white Apple cerif.
    X509_STORE * store = X509_STORE_new();
    X509 * appleRootCA = d2i_X509_bio(b_x509, NULL);
    X509_STORE_add_cert(store, appleRootCA);

    // Verify the Signature

    BIO * b_receiptPayload = BIO_new(BIO_s_mem());
    int result = PKCS7_verify(p7, NULL, store, NULL, b_receiptPayload, 0);
    NSLog(@"Result == %i", result); 
Run Code Online (Sandbox Code Playgroud)

但结果始终为0而不是1. …

xcode openssl x509certificate ios

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

用于加入子查询的JPA CriteriaBuilder

我有这样的SQL语句:

SELECT * FROM person inner join (select max(validityId) as maxID from person group by personId) maxID on maxID.maxID = person.validityid;
Run Code Online (Sandbox Code Playgroud)

因此它为personID提供了"不同"的行:

如果我有这样的表:

|  personID  |  validitID | value   |
-------------------------------------------
|    1       |    10      | 400     |
|    1       |    11      | 500     |
|    1       |    12      | 600     |
|    2       |    13      | 700     |
|    2       |    14      | 800     |
|    2       |    15      | 900     |
|    4       |    16      | 1000    | …
Run Code Online (Sandbox Code Playgroud)

sql hibernate jpa

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

iOS上数组的Swift Metal并行和计算

基于@Kametrixom 答案,我已经做了一些测试应用程序来并行计算数组中的总和。

我的测试应用程序如下所示:

import UIKit
import Metal

class ViewController: UIViewController {

// Data type, has to be the same as in the shader
typealias DataType = CInt

override func viewDidLoad() {
    super.viewDidLoad()

    let data = (0..<10000000).map{ _ in DataType(200) } // Our data, randomly generated


    var start, end : UInt64


    var result:DataType = 0
    start = mach_absolute_time()
    data.withUnsafeBufferPointer { buffer in
        for elem in buffer {
            result += elem
        }
    }
    end = mach_absolute_time()

    print("CPU result: \(result), time: \(Double(end …
Run Code Online (Sandbox Code Playgroud)

arrays posix-api ios swift metal

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