I am pretty much an XCode beginner, and I therefore tried the, "Hello World" example given in the XCode documentation: Quick Start Guide: Tutorial: Using Xcode to Write “Hello, World!” for OS X.
I am using XCode 4.5.1 from whose documentation I took this example using OS 10.8.2. I followed the instructions; the example didn't work. It produced the window but not the "hello world" printing. The relevant code is:
- (void)drawRect:(NSRect)dirtyRect
{
// Drawing code here.
NSString *hello = @"Hello, World!";
NSPoint point =NSMakePoint(15, 75);
NSMutableDictionary *font_attributes = [[NSMutableDictionary alloc] init];
NSFont *font = [NSFont fontWithName:@"Futura-MediumItalic" size:42];
[font_attributes setObject:font forKey:NSFontAttributeName];
[hello drawAtPoint:point withAttributes:font_attributes];
[font_attributes release];
}
There are two notable things. The last line of this code gives an error:
release is unavailable: not available in automatic reference counting mode
So I commented this line out and ran the program. The window appeared, but no "Hello World". A long message appeared in the All Output, part of which read:
"/Users/me/Library/ScriptingAdditions/YouHelper.osax/Contents/MacOS/YouHelper: no matching architecture in universal wrapper
Hello: OpenScripting.framework - scripting addition "/Users/me/Library/ScriptingAdditions/YouHelper.osax" declares no loadable handlers."
Am I doing something dumb, or am I using the wrong example?
You have to remove [font_attributes release]; at the end of your code.
release, retain, alloc and dealloc are not available in ARC(Automatic Reference Counting). This is what the error says.
And for the second error you should remove anything that is referring to AppleScript and similar scripting addons for the app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With