Link to userlib : http://www.w73.nl/pb/libPBObjC.zip
Procedures
OC_AutoreleasePool() - Returns a NSAutoreleasePool object.
OC_DrainAutoreleasePool (NSAutoreleasePool) - Drains a NSAutoreleasePool object.
OC_NSNumber (Float.f) - Convert a Float to a NSNumber.
OC_FloatFromNSNumber (NSNumber) - Convert a NSNumber to a Float.
OC_NSString (String.s) - Convert String to NSString.
OC_StringFromNSString (NSString) - Convert NSString to String.
OCA (ClassName.s) - Get class from class name and alloc.
OCC (ClassName.s) - Get class from class name.
OCS (SelectorName.s) - Get selector from selector name.
OCM (TheReceiver, TheSelector [, ... arguments]) - Send a message.
OCMF (TheReceiver, TheSelector [, ... arguments]) - Send a message that returns a float.
OCMS (*StructureReturnAddress, TheReceiver, TheSelector [, ... arguments]) - Send a message that returns a structure.
OCKV (TheReceiver, Key.s [, Value]) - Gets or sets a value for a key.
OC_AppleScript (Script.s) - Execute AppleScript code.
Example
Code: Select all
Structure CGRect
x.f
y.f
w.f
h.f
EndStructure
If OpenWindow(0, 0, 0, 320, 220, "Cocoa Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
; create a NSWindow object from the current window
CocoaWindow = OCM(OCA("NSWindow"), OCS("initWithWindowRef:"), WindowID(0))
; get the content view of the NSWindow
ContentView = OCM(CocoaWindow, OCS("contentView"))
Frame.CGRect\x = 0
Frame\y = y
Frame\w = 120
Frame\h = 30
; create and add a button
Btn = OCM(OCA("NSButton"), OCS("initWithFrame:"), PeekL(Frame), PeekL(Frame + 4), PeekL(Frame + 8), PeekL(Frame + 12))
OCM(Btn, OCS("setBezelStyle:"), 1)
OCM(ContentView, OCS("addSubview:"), Btn)
OCM(Btn, OCS("setTitle:"), OC_NSString("Cocoa Button"))
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
It does show a Cocoa button but for some reason it disappears when clicked.