Marketplace board now live! Post those eBay finds!
Quote from: jeffburg on Sep 25, 2025, 02:09 PMI'm glad it works! And yeah, great catch! I totally missed it! NSBezierPath was introduced in OSX, so it won't work in OpenStep.Interesting, is NSBezierPath() a commonly used function on OSX? I wonder if that function is in Rhapsody DR2?
Quote from: jeffburg on Sep 25, 2025, 02:09 PMBut yeah, think of the code troubleshooting like you would hardware troubleshooting. For example, if the computer won't boot and the error is related to RAM failure... what do you do first? Remove all the RAM except for 1 stick and boot again. If it boots, you put in another stick and try again. If it boots again you put in another stick of RAM over and over until it stops booting. Then you have found your bad stick of RAM.
Then when you master this technique you move on to the next technique which is split-half search. Remove half of the RAM and boot the computer. If it boots up, then you put all the RAM back and remove the other half. Then it should fail to boot, and you remove half of the remaining RAM and see if it boots. By moving back and forth in halves instead of 1 at a time, you double your troubleshooting speed![]()
https://www.oreilly.com/library/view/apple-training-series/0321335465/0321335465_ch03lev1sec3.html
Quote from: jeffburg on Sep 25, 2025, 08:20 AM@ptek I saw your Discord message that its still not compiling. So here is what I would do. Reduce the file to the absolute bare minimum needed and keep adding things until it breaks again.
#import <AppKit/AppKit.h>
@interface DemoView: NSView
{
}
- (void)drawRect:(NSRect)rect;
@end
@implementation DemoView
- (void)drawRect:(NSRect)rect;
{
[[NSColor redColor] set]; // set the drawing color to red
NSRectFill([self bounds]); // fill the view with red
}
-(void)windowWillClose:(NSNotification*)notification;
{
[NSApp terminate:self];
}
@end
void setup(void)
{
NSWindow *myWindow;
NSView *myView;
NSRect graphicsRect;
graphicsRect = NSMakeRect(100.0, 350.0, 400.0, 400.0);
myWindow = [ [NSWindow alloc]
initWithContentRect: graphicsRect
styleMask:NSTitledWindowMask
|NSClosableWindowMask
|NSMiniaturizableWindowMask
backing:NSBackingStoreBuffered
defer:NO ];
[myWindow setTitle:@"Tiny Application Window"];
// Change this back to DemoView
myView = [[[DemoView alloc] initWithFrame:graphicsRect] autorelease];
[myWindow setContentView:myView ];
[myWindow setDelegate:myView ];
[myWindow makeKeyAndOrderFront: nil];
}
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSApp = [NSApplication sharedApplication];
setup(); // uncomment this because we now have a setup function
[NSApp run];
[NSApp release];
[pool release];
return(EXIT_SUCCESS);
}
- (void)drawRect:(NSRect)rect // instance method implementation
{
double f,g;
double const pi = 2 * acos(0.0);
int n = 12;
NSPoint p1,p2; <---- declare the variables at the beginning
float width = [self bounds].size.width;
float height = [self bounds].size.height;
[[NSColor whiteColor] set];
NSRectFill([self bounds]);
[[NSColor blackColor] set];
for (f=0; f<2*pi; f+=2*pi/n) {
for (g=0; g<2*pi; g+=2*pi/n) {
p1 = NSMakePoint(X(f),Y(f));
p2 = NSMakePoint(X(g),Y(g)); <------ remove the NSPoint to reuse the existing variables instead of declaring new ones
[NSBezierPath strokeLineFromPoint:p1 toPoint:p2];
}
}
}
Quote from: jeffburgThis is interesting. When I removed the NIB's from my App, OpenStep 4.2 was not happy about it. Particularly the Menus in OS4.2 are not retained by NSApplication, instead they are retained by their NIB which seems crazy to me but that's how it is. So the app would always crash after launching because the menus would be released from memory and then NSApplication would try to access them so it could render them.
for (f=0; f<2*pi; f+=2*pi/n) { // draw the fancy pattern
for (g=0; g<2*pi; g+=2*pi/n) {
NSPoint p1 = NSMakePoint(X(f),Y(f)); <---- These are new variables declared in the middle of the function
NSPoint p2 = NSMakePoint(X(g),Y(g));
[NSBezierPath strokeLineFromPoint:p1 toPoint:p2];
}
}
- (void)drawRect:(NSRect)rect // instance method implementation
{
double f,g;
double const pi = 2 * acos(0.0);
int n = 12;
NSPoint p1,p2; <---- declare the variables at the beginning
float width = [self bounds].size.width;
float height = [self bounds].size.height;
[[NSColor whiteColor] set];
NSRectFill([self bounds]);
[[NSColor blackColor] set];
for (f=0; f<2*pi; f+=2*pi/n) {
for (g=0; g<2*pi; g+=2*pi/n) {
p1 = NSMakePoint(X(f),Y(f));
p2 = NSMakePoint(X(g),Y(g)); <------ remove the NSPoint to reuse the existing variables instead of declaring new ones
[NSBezierPath strokeLineFromPoint:p1 toPoint:p2];
}
}
}
#import <AppKit/AppKit.h>
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSApp = [NSApplication sharedApplication];
// setup(); // comment this out because we have no setup function yet
[NSApp run];
[NSApp release];
[pool release];
return(EXIT_SUCCESS);
}
#import <AppKit/AppKit.h>
void setup(void)
{
NSWindow *myWindow;
NSView *myView;
NSRect graphicsRect;
graphicsRect = NSMakeRect(100.0, 350.0, 400.0, 400.0);
myWindow = [ [NSWindow alloc]
initWithContentRect: graphicsRect
styleMask:NSTitledWindowMask
|NSClosableWindowMask
|NSMiniaturizableWindowMask
backing:NSBackingStoreBuffered
defer:NO ];
[myWindow setTitle:@"Tiny Application Window"];
// Change this to NSView because we have no implemented DemoView yet
myView = [[[NSView alloc] initWithFrame:graphicsRect] autorelease];
[myWindow setContentView:myView ];
[myWindow setDelegate:myView ];
[myWindow makeKeyAndOrderFront: nil];
}
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSApp = [NSApplication sharedApplication];
setup(); // uncomment this because we now have a setup function
[NSApp run];
[NSApp release];
[pool release];
return(EXIT_SUCCESS);
}
#import <AppKit/AppKit.h>
@interface DemoView: NSView
{
}
- (void)drawRect:(NSRect)rect;
@end
@implementation DemoView
- (void)drawRect:(NSRect)rect;
{
}
-(void)windowWillClose:(NSNotification*)notification;
{
}
@end
void setup(void)
{
NSWindow *myWindow;
NSView *myView;
NSRect graphicsRect;
graphicsRect = NSMakeRect(100.0, 350.0, 400.0, 400.0);
myWindow = [ [NSWindow alloc]
initWithContentRect: graphicsRect
styleMask:NSTitledWindowMask
|NSClosableWindowMask
|NSMiniaturizableWindowMask
backing:NSBackingStoreBuffered
defer:NO ];
[myWindow setTitle:@"Tiny Application Window"];
// Change this back to DemoView
myView = [[[DemoView alloc] initWithFrame:graphicsRect] autorelease];
[myWindow setContentView:myView ];
[myWindow setDelegate:myView ];
[myWindow makeKeyAndOrderFront: nil];
}
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSApp = [NSApplication sharedApplication];
setup(); // uncomment this because we now have a setup function
[NSApp run];
[NSApp release];
[pool release];
return(EXIT_SUCCESS);
}
#import <AppKit/AppKit.h>
@interface DemoView: NSView
{
}
- (void)drawRect:(NSRect)rect;
@end
@implementation DemoView
- (void)drawRect:(NSRect)rect;
{
[[NSColor redColor] set]; // set the drawing color to red
NSRectFill([self bounds]); // fill the view with red
}
-(void)windowWillClose:(NSNotification*)notification;
{
[NSApp terminate:self];
}
@end
void setup(void)
{
NSWindow *myWindow;
NSView *myView;
NSRect graphicsRect;
graphicsRect = NSMakeRect(100.0, 350.0, 400.0, 400.0);
myWindow = [ [NSWindow alloc]
initWithContentRect: graphicsRect
styleMask:NSTitledWindowMask
|NSClosableWindowMask
|NSMiniaturizableWindowMask
backing:NSBackingStoreBuffered
defer:NO ];
[myWindow setTitle:@"Tiny Application Window"];
// Change this back to DemoView
myView = [[[DemoView alloc] initWithFrame:graphicsRect] autorelease];
[myWindow setContentView:myView ];
[myWindow setDelegate:myView ];
[myWindow makeKeyAndOrderFront: nil];
}
int main(int argc, char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSApp = [NSApplication sharedApplication];
setup(); // uncomment this because we now have a setup function
[NSApp run];
[NSApp release];
[pool release];
return(EXIT_SUCCESS);
}