Skip to content

Commit 6846e2f

Browse files
committed
Add NSArray
1 parent 193dfe4 commit 6846e2f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

core/NSArray.go

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package core
2+
3+
import (
4+
"github.com/progrium/macdriver/objc"
5+
)
6+
7+
import "C"
8+
9+
// NSArray is a static ordered collection of objects.
10+
// https://developer.apple.com/documentation/foundation/nsarray?language=objc
11+
type NSArray struct {
12+
objc.Object
13+
}
14+
15+
// NSArray_WithObjects creates and returns an array containing the objects in the argument list.
16+
// https://developer.apple.com/documentation/foundation/nsarray/1460068-initwithobjects?language=objc
17+
func NSArray_WithObjects(objs ...objc.Object) NSArray {
18+
objsInterface := make([]interface{}, len(objs))
19+
for i, obj := range objs {
20+
objsInterface[i] = obj
21+
}
22+
return NSArray{objc.Get("NSArray").Send("arrayWithObjects:", objsInterface...)}
23+
}
24+
25+
// Count returns the number of objects in the array.
26+
// https://developer.apple.com/documentation/foundation/nsarray/1409982-count?language=objc
27+
func (a NSArray) Count() uint64 {
28+
return a.Get("count").Uint()
29+
}
30+
31+
// ObjectAtIndex returns the object located at the specified index.
32+
// https://developer.apple.com/documentation/foundation/nsarray/1417555-objectatindex?language=objc
33+
func (a NSArray) ObjectAtIndex(i uint64) objc.Object {
34+
return a.Send("objectAtIndex:", i)
35+
}
36+

0 commit comments

Comments
 (0)