小编val*_*rij的帖子

从具有NSArray返回值的方法返回NSMutableArray对象

从使用a动态构建数组的方法返回NSArray(或NSDictionary等)NSMutableArray时,使用ARC时执行此操作并避免随机内存泄漏的标准方法是什么?

例如,假设我们有一些带有名称列表的类,我们想手动过滤并获取以给定字母开头的所有名称:

- (NSArray *)getNamesByFirstLetter:(NSString *)firstLetter 
{
    NSMutableArray *returnValue = [[NSMutableArray alloc] init];
    for(id item in self.names)
    {
        if([item hasPrefix:firstLetter])
        {
            [returnValue addObject:item];
        }
    }        
    return returnValue; // just return the above array
}
Run Code Online (Sandbox Code Playgroud)

在返回值时,我可以想到四种可能的方法:

  1. NSMutableArray直接退货(如上)

    return returnValue;
    
    Run Code Online (Sandbox Code Playgroud)
  2. 回来一个 copy

    return [returnValue copy];
    
    Run Code Online (Sandbox Code Playgroud)
  3. 返回使用NSArray arrayWithArray:

    return [NSArray arrayWithArray:returnValue];
    
    Run Code Online (Sandbox Code Playgroud)
  4. 创建一个NSArray,手动设置NSMutableArraynil:

    NSArray *temp = [NSArray arrayWithArray:returnValue]; // could use [returnValue copy] here too
    returnValue = nil;
    return …
    Run Code Online (Sandbox Code Playgroud)

objective-c automatic-ref-counting

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

简化嵌套if else条件

我有这个嵌套的if else条件.我想要的检查流程在下面的代码中描述.

if (HiringManagerAPPROVED)
{ 
    //email reporting gropu
}
else if (ReportingGroupAPPROVED)
{ 
    //email Hiringmanager
}
else if (HiringManagerReAPPROVED)
{ 
    //email PPO
}                }
else if (PpoAPPROVED)
{ 
    //email Finance
}
else if (FinanceAPPROVED)
{ 
    //email president & COO
}
else if (PresidentCooAPPROVED)
{ 
    //email hr
}
else if (HRAPPROVED)
{
    //email Hiring Manager
}
Run Code Online (Sandbox Code Playgroud)

如何减少支票数量,保持支票流量不变.

c# asp.net if-statement nested-if

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

为Azure Search索引Blob内容时,"内容"过大

我按照本文所述为Azure设置blob索引和全文搜索:使用Azure搜索在Azure Blob存储中索引文档.

我的一些文档在索引器中失败,导致返回以下错误:

字段"内容"包含的字词太大而无法处理.UTF-8编码术语的最大长度为32766字节.导致此错误的最可能原因是在此字段上启用了筛选,排序和/或分面,这会导致整个字段值被索引为单个术语.请避免在大字段中使用这些选项.

产生此错误的特定pdf是3.68 MB,包含各种内容(文本,表格,图像等).

索引和索引器的设置与该文章中描述的完全相同,但增加了一些文件类型限制.

指数:

{
    "name": "my-index",
    "fields": [{
        "name": "id",
        "type": "Edm.String",
        "key": true,
        "searchable": false
    }, {
        "name": "content",
        "type": "Edm.String",
        "searchable": true
    }]
}
Run Code Online (Sandbox Code Playgroud)

索引:

{
    "name": "my-indexer",
    "dataSourceName": "my-data-source",
    "targetIndexName": "my-index",
    "schedule": { 
        "interval": "PT2H"
    },
    "parameters": {
        "maxFailedItems": 10,
        "configuration": {
            "indexedFileNameExtensions": ".pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.html,.xml,.eml,.msg,.txt,.text"
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我尝试搜索他们的文档和其他一些相关文章,但我找不到任何信息.我猜这是因为此功能仍在预览中.

azure azure-storage-blobs azure-cognitive-search

0
推荐指数
1
解决办法
879
查看次数