ghostty/pkg/objc/class.zig
Mitchell Hashimoto dd8fde52d9 pkg/objc starting
2022-10-25 16:21:11 -07:00

21 lines
513 B
Zig

const std = @import("std");
const c = @import("c.zig");
pub const Class = struct {
value: c.Class,
/// Returns the class definition of a specified class.
pub fn getClass(name: [:0]const u8) ?Class {
return Class{
.value = c.objc_getClass(name.ptr) orelse return null,
};
}
};
test {
const testing = std.testing;
const NSObject = Class.getClass("NSObject");
try testing.expect(NSObject != null);
try testing.expect(Class.getClass("NoWay") == null);
}