我有两个NSArray例如
Arr1 = [" anw1 ...,.."],[" anw2 ...,..."],[" anw3,。 .."],[" anw4,..."]
Arr2 = [" arrm1"," ...."],[" arrm2",...],[" arrm3& #34;,...],[" arrm4",...],[" arrm5",...]
如何将Arr1
和Arr2
NSArray合并到一个NSArray中,如下例所示?。
newarr
的输出:
Newarr = [" anw1 ...,.."],[" arrm1"," ...."],[&# 34; arrm2",...], [" arrm3",...],[" arrm4",...], [" arrm5",...],[" anw2 ...,..."],[" arrm1"" .. .."],[" arrm2",...], [" arrm3",...],[" arrm4",...], [" arrm5",...],[" anw3,..."],[" arrm1""&.... #34;],[" arrm2",...], [" arrm3",...],[" arrm4",...], [" arrm5",...],[" anw4,..."],[" arrm1""&.... #34;],[" arrm2",...], [" arrm3",...],[" arrm4",...],[" arrm5",...]
答案 0 :(得分:1)
正如其他人所说,不要使用Swift的NSArrays。使用Swift数组。
其次,变量名应以小写字母开头,因此Arr1应该是arr1,而Arr2应该是arr2。
然后你的代码看起来像这样:
var result: [String] = []
let arr1 = ["string1", "string2", "string3", "string4"]
let arr2 = ["filler1", "filler2", "filler3", "filler4"]
for item in arr1 {
result.append(item)
result.append(contentsOf: arr2)
}
答案 1 :(得分:1)
雨燕5
Sub MovingEmails_Invoices()
'Declare your Variables
Dim items As Outlook.items
Dim subfolder As Outlook.Folder 'this will be the folder you want to move the Mail to
'Set Outlook Inbox Reference
Set OP = New Outlook.Application
Set NS = OP.GetNamespace("MAPI")
Set Mail = OP.CreateItem(olMailItem)
'To loop through subfolder and its folders
Set rootfol = NS.Folders("SYNTHES-JNJCZ-GBS.DE.AT.CH@ITS.JNJ.com")
Set Folder = rootfol.Folders("Austria")
'The list for invoice number should be dynamic
Dim arraysearch(1 To 1000) As String
Dim i As Long
i = UBound(arraysearch)
arraysearch(i) = Range("C2").offset(i, 0).Value
If i = 0 Then
MsgBox "error"
Exit Sub
End If
'The list for folder type should be dynamic
Dim arraymove(1 To 1000) As String
i = UBound(arraymove)
arraymove(i) = Range("H2").offset(i, 0).Value
If i = 0 Then
MsgBox "error"
Exit Sub
End If
'specific folders for the mail to move to
Set subfolder = rootfol.Folders(arraymove(i))
For Each Mail In Folder.items.Restrict("[Subject] >= arraysearch(i)")
If arraysearch(i) = arraymove(i) Then
item.Move subfolder
End If
Next Mail
End Sub
答案 2 :(得分:0)
只需创建一个新的NSArray并将其组合成两个
let ar1:NSArray = [3, 5, 7]
let ar2:NSArray = [4, 6, 8]
let ar3 = ar1.addingObjects(from: ar2 as! [Any])
print(ar3)
应输出[3, 5, 7, 4, 6, 8]
但实际上,你不应该使用带有Swift的NSArray。
答案 3 :(得分:0)
尝试这样:
var Arr1 = [["anw1...,.."], ["anw2...,..."],["anw3,..."],["anw4,..."]]
var Arr2 = [["arrm1,...."], ["arrm2,..."], ["arrm3,..."], ["arrm4,..."], ["arrm5,..."]]
let Arr = Arr1 + Arr2
print(Arr)
// outPut:[[“ anw1 ...,..”],[“ anw2 ...,...”],[“ anw3,...”],[“ anw4,... “],[” arrm1,....“],[” arrm2,...“],[” arrm3,...“],[” arrm4,...“],[” arrm5,.. 。”]