Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@amro
Last active August 19, 2023 21:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amro/52846ea9c6eb3238b793 to your computer and use it in GitHub Desktop.
Save amro/52846ea9c6eb3238b793 to your computer and use it in GitHub Desktop.
Using an Instance of NSOrderedSet from Swift
// How one might use NSMutableOrderedSet from Swift -- mainly an example of how to
// call Objective-C classes from Swift. Pretty much what one would expect.
var set = NSMutableOrderedSet()
set.addObject("foo");
set.addObject("bar");
set.addObjectsFromArray(["bar", "wee", "foo"])
for i in 0..set.count {
println(set.objectAtIndex(i))
}
//Output
foo
bar
wee
@JonMercer
Copy link

Updated from Aug 19 2023

var set = NSMutableOrderedSet()
set.add("foo");
set.add("bar");
set.addObjects(from: ["bar", "wee", "foo"])

print(set.count)
for i in 0..<set.count {
	print(set.object(at: i))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment