Reputation: 873
I have data stored in a [NSDictionary]()
here is how I add the data:
var usedObjectDictionaries = [NSDictionary]()
for firstUseItem in useItemsInFirstObject {
let dict = firstUseItem.toDictionary()
usedObjectDictionaries.append(dict)
}
And the [NSDictionary]()
if printed out looks like this:
What I need to do is reach the value of the ActivityReference1
in the [NSDictionary]()
.
Meaning , how can I get to the Job
.
Upvotes: 0
Views: 311
Reputation: 131491
@MarieDM's answer of using array indexing will work, but it will crash if the array is empty.
You could also use
if let activity = userObjectDictionaries.first["ActivityReference1"] {
//here "activity" contains the entry from the first entry
} else {
//This code will execute
//if there are no entries in userObjectDictionaries
}
Upvotes: 0
Reputation: 2727
To get the first one:
usedObjectDictionaries[0]["ActivityReference1"]
Upvotes: 0
Reputation: 19602
for item in usedObjectDictionaries {
print(item["ActivityReference1"])
}
Upvotes: 2